Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

Regular expressions with ExpectJ

$
0
0

I've been used the ExpectJ Java library to automate some jobs on a Linux server, however now I need to automate a job that sends a different text response for each execution. Here is the output:

Last unsuccessful login: Fri Mar 30 15:21:31 CST 2012 
********************************************************************************

********************************************************************************
[YOU HAVE NEW MAIL] 
local-login [/home/user]%

And in my code I have the following:

s.expect("Login as:");
s.send("userlogin\n");
s.expect("userlogin@iphost's password:");
s.send("password\n");

I receive the output shown, but I wasn't be able to send the next command because I don't know how read the last answer, I tried to use a regular expression but it doesn't work.


Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>