-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Reported by shamsnez...@gmail.com, May 22, 2010
What steps will reproduce the problem?
-
I want to use expect4j for ftp but it is not working, the following is
my code
public static void main( String[] args )
{
String command1 = "ftp";
String command2 = "open 127.0.0.1";
String command3 = "get ftp.txt ftp.txt";
final String username = "msn";
final String password = "nezami";
try
{
System.out.println( "FtpTest started ..." );
Expect4j expect = ExpectUtils.spawn( command1 );
expect.setDefaultTimeout( Expect4j.TIMEOUT_DEFAULT );
expect.send( command2 + "\n" );
DataClosure userNameClosure = new DataClosure( expect, username
);
DataClosure passwordClosure = new DataClosure( expect, password
);
Match match[] =
{ new GlobMatch( "User", userNameClosure ), new GlobMatch(
"Password", passwordClosure ) };
expect.expect( match );
expect.send( command3 + "\n" );
expect.close();
System.out.println( "FtpTest completed ..." );
}
catch ( Exception ex )
{
ex.printStackTrace();
}
}
public class DataClosure
implements Closure
{
Expect4j expect;
String data;
public DataClosure()
{
}
public DataClosure( Expect4j expectParam, String dataParam )
{
expect = expectParam;
data = dataParam;
}
public void run( ExpectState state )
throws Exception
{
try
{
expect.send( data + "\n" );
}
catch ( Exception e )
{
System.out.println(e.getMessage());
Expect4j.log.warning( e.getMessage() );
}
System.out.println(data +" sent");
state.addVar( data, Boolean.TRUE );
state.exp_continue();
}
}
What is the expected output? What do you see instead?
It should download a existing file from ftp to current directory
What version of the product are you using? On what operating system?
version 1.0 on windows xp3
Please provide any additional information below.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels