![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automated SFTP script | aggar_y | Shell Programming and Scripting | 6 | 08-05-2008 11:39 AM |
| automated sftp script | klindel | Shell Programming and Scripting | 2 | 05-12-2008 10:45 PM |
| Intrusion Interrupted - Microsoft Certified Professional | iBot | UNIX and Linux RSS News | 0 | 07-29-2007 01:40 AM |
| automated ftp. | sangfroid | Shell Programming and Scripting | 10 | 05-07-2007 08:52 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dear experts,
I have a local computer and remote computer (only sftp accessed). I want to delete files x and y in both local and remote computer using the following automated script: sftp $remote > /dev/null < mdel.file the file mdel.file has been pre-created, and its content is cd /usr/directory rm x rm y The script works fine when both files x and y exhist in $remote computer. The script is interrupted when file x does not exhist in $remote computer. And therefore, the file y is not removed. My question is, can I be able to remove file y in case the file x is not exhist? The reason is that I can not gurantted that the file x exhist. Many thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
When I tested this myself the script just continued on and removed the second file anyway. If you remove the > /dev/null do you get any clues about why it is exiting?
Code:
$ touch delete1 delete2 $ echo 'rm delete1 > rm delete2' | sftp localhost Connecting to localhost... sftp> rm delete1 Removing /home/username/delete1 sftp> rm delete2 Removing /home/username/delete2 $ touch delete2 $ echo 'rm delete1^Jrm delete2' | sftp localhost Connecting to localhost... sftp> rm delete1 Couldn't stat remote file: No such file or directory Removing /home/username/delete1 Couldn't delete file: No such file or directory sftp> rm delete2 Removing /home/username/delete2 $ |
|
#3
|
|||
|
|||
|
Thanks.
Boyin |
|||
| Google The UNIX and Linux Forums |