The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-04-2008
Registered User
 

Join Date: May 2008
Posts: 2
Question automated sftp procedure interrupted

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
Reply With Quote
Forum Sponsor
  #2  
Old 05-04-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 917
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
$
Reply With Quote
  #3  
Old 05-06-2008
Registered User
 

Join Date: May 2008
Posts: 2
Thanks.

Boyin
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0