![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get the exit status | yhacks | Shell Programming and Scripting | 1 | 05-19-2008 08:06 AM |
| exit status | moxxx68 | Shell Programming and Scripting | 1 | 12-04-2004 07:27 PM |
| Checking the exit status of ftp | psingh | UNIX for Advanced & Expert Users | 1 | 06-04-2002 10:51 PM |
| tar exit status | thorndike | UNIX for Dummies Questions & Answers | 3 | 01-22-2002 04:39 PM |
| ftp exit status. | oracle8 | UNIX for Advanced & Expert Users | 1 | 10-21-2001 11:34 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Exit Status of SFTP
I have a shell script which delivers the file to the SERVER B using SFTP.
I'm calling this script from java. Now I need to find the exit status of the sftp, with the help of this I can find whether it was success or unsucess. I'm using the variable "$?" to get the status and it is always 0 even if it not able to deliver the file. Can anyone please help me out in this. This is very urgent. Here is the script: sftp $1@$2 <<EOC cd $3 lcd $4 put $5 EOC if [ $? -ne 0 ] then echo "SFTP ERROR" >> FILE exit 9 fi echo "SFTP Complete" >> FILE Here is the java code: //Execute the shell script which drops the file to destination using SFTP Process process = runtime.exec("sftpFile.sh" +" " +user+" " + host+" " + targetfile+" " + localDir +" "+fileName,null,dir); process.waitFor(); Any help is appreciated. Thanks in Advance |
|
||||
|
ftp and sftp are supposed to write status codes(ftp) or messages(sftp) to stdout, the $? value of sftp, if it connects okay to a remote host, will be 0. The status of an individual operation is displayed on stdout. "OK" means whatever operation was attempted completed succesfully.
However, the actual text you get back may depend on whose sftp you use. So checking for errors is interesting. Consider libcurl classes for your java? There are libcurl routines that will perform sftp operations and give you a status back. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|