automated sftp procedure interrupted


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting automated sftp procedure interrupted
# 1  
Old 05-04-2008
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
# 2  
Old 05-04-2008
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  
Old 05-06-2008
Thanks.

Boyin
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automated passwd protected sftp

I am trying to automate the process using password protected sftp upload the file in daily basis from our server to client server and exit successfully from remote server Getting issue while running the script. sftp test@12.342.564.205/passwd--password for sftp cd /home/group/jagu/txt put... (3 Replies)
Discussion started by: jagu
3 Replies

2. UNIX for Dummies Questions & Answers

Is original file modified when pigz is interrupted?

I had to stop a pigz (parallel gzip) compression before it completed. Is the original uncompressed file changed/corrupted? I was under the impression that the original file is not changed during compression, though it is deleted if the compression is successful. (1 Reply)
Discussion started by: colin123
1 Replies

3. OS X (Apple)

Folder location interrupted

Have had hidden/interrupted folder. It is on a NTFS-partition I use for OS and Bootcamp. I think that the problem is a HFS+ problem. I happened with all the folder which had a slash "/" in their folder name. So for example I had the folder "test/rand". Recently it disappeared from finder. In... (9 Replies)
Discussion started by: sceltecs
9 Replies

4. UNIX Desktop Questions & Answers

arecord not interrupted after specified duration

I have used the arecord command like this arecord -d 1 test.wav It is keep on waiting. I need to manually interrupt it by ctrl-c. Why it is not interrupting after one second? The arecord version which I am using is : arecord: version 1.0.23 by Jaroslav Kysela (3 Replies)
Discussion started by: thillai_selvan
3 Replies

5. Programming

Problem with signal handler and interrupted system call

Hi, I have a daq program that runs in an infinite loop until it receives SIGINT. A handler catches the signal and sets a flag to stop the while loop. After the loop some things have to be cleaned up. The problem is that I want my main while loop to wait until the next full second begins, to... (2 Replies)
Discussion started by: soeckel
2 Replies

6. Shell Programming and Scripting

sftp automated script

HI, Can anyone has automated sftp script? I want to upload one file from one server to other. Could anyone help us? (3 Replies)
Discussion started by: javeed7
3 Replies

7. Shell Programming and Scripting

Automated SFTP script

Hi All, I am writing an automated SFTP script to xfer files. I am able to do sftp in batch mode and it is working absolutely fine. The problem is that on redirecting the output of SFTP session to some file, it is not writing about the status of SFTP operation. All i can see in output file is :... (6 Replies)
Discussion started by: aggar_y
6 Replies

8. Shell Programming and Scripting

automated sftp script

Ok, I am sure this has been beat like a dead horse, but I an trying "anew". I am trying to create a script that will automate a file transfer using sftp. Please, I am at rock bottom. Thank you. (2 Replies)
Discussion started by: klindel
2 Replies
Login or Register to Ask a Question