Hi,
Ya Vugen and LG is in the same machine. Just the controller is in the different machine.
What the script is trying to do is FTP some files from my local to the FTP server. My script looks something like this
/*
* LoadRunner Java script. (Build: 3020)
*
* Script Description:
*
*/
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import org.apache.commons.io.*;
import com.jcraft.jsch.*;
import lrapi.lr;
public class Actions
{
int j=0;
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
JSch jsch=new JSch();
String host="<hostName>";
String user= "<userName>";
String pwd= "<password>";
int port=22;
try {
Session session=jsch.getSession(user, host, port);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword(pwd);
session.connect();
//SFTP get
Channel channel = session.openChannel("sftp");
channel.setXForwarding(true);
channel.connect();
ChannelSftp sftp = (ChannelSftp) channel;
//get all files under one directory.
File srcfile=new File ("<sourceFolder>");
if (srcfile.isDirectory())
{
File []srcfilelist=srcfile.listFiles();
j=0;
for( ;j < srcfilelist.length;j++){
if (srcfilelist[j].isFile()) {
lr.log_message(srcfilelist[j].toString()+srcfilelist[j].getName());
sftp.cd("<Destination>");
sftp.put(srcfilelist[j].toString(), srcfilelist[j].getName());
}
}
}
sftp.quit();
session.disconnect();
}
catch (Exception e){
System.out.println(e);
}
//LCstart
//System.exit(0);
//LCend
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}