linux - how to run a bash program from windows in unix using java -


i trying run program process file window using jcraft library in unix. found after establishing channel try run program in home directory need run in separate directory.please have tried far , let me know missing.

string strremotedir = "/home/process/input" channel = session.openchannel("sftp");

    channel.connect();     system.out.println("sftp channel opened , connected.");     channelsftp = (channelsftp) channel;     // printing home directory in unix server     system.out.println(channelsftp.gethome());     channelsftp.cd(strremotedir);    system.out.println(channelsftp.pwd());    // uploading file need run program     file f = new file(filename);     channelsftp.put(new fileinputstream(f), f.getname());     system.out.println("file transfered host.");     filetransfer = true;      channel=session.openchannel("exec");     inputstream in=channel.getinputstream();     // printing desired directory want go     system.out.println(channelsftp.pwd());     ((channelexec)channel).setcommand("sh process.ksh "a.txt");     channel.setinputstream(null);     ((channelexec)channel).seterrstream(system.err);      channel.connect(); 

output : process.ksh not found

but through putty able run program. let know process.ksh not in input directory, has capability run anywhere arguments. ((channelexec)channel).setcommand("ls") prints out files home directory. believe establishing channel home directory, don't know how run bash program using jcraft in desired location.please let me know missing or possible make happen.

thanks in advance. nur

"sftp" channel not made execute shell command sftp command only.

    channel channel = session.openchannel("shell");     cmdsend = channel.getoutputstream();     inputstream cmdrcv = channel.getinputstream();     // start thread reading , displaying cmdrcv      channel.connect(3000);     thread.sleep(1000);      cmdsend.write("cd /to/the/right/dir\n".getbytes());     cmdsend.flush();     cmdsend.write("sh process.ksh \"a.txt\"\n".getbytes());     cmdsend.flush(); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -