I am currently writing a script to send files to a server over sftp. When the sftp put command succeeds it wil preform a local move from within the sftp shell to another folder (this is done so when the script is rerun no doubles will be sent).
therefore i had following sollution
so basically first i put the file over sftp and then create a checkfile (for a following script) followed by the remove (again the checkfile will be overwritten here)
This would work perfectly if the sftpshell (or even this whole script for that matter) would stop and go in error on a failed !rm or put. This is not the case however. After the !rm fails (just tested) it just continues to put the next file.
the whole idea is that the following script would check the content of the generated checkfile and based on its content it will send us a message saying to check manually because the local remove failed.
Also i was ordered not to make a separate connection for each file (so the sftp batch is in fact nescessary)
I hope someone can help because this problem is driving me crazy.
Also i already tried the set -e option at the beginning of this script but this doesnt appear to work for an sftp batch.
You could always have the tests and control external. If you have SFTP working, can you also SSH login to the same server as that account? Perhaps a controlling local script could put a single file with SFTP, then an audit and rename could be done by an SSH connection where you can then recognise errors.
sftp rm should abort on fail, according to the man page:
Quote:
-b batchfile
Batch mode reads a series of commands from an input batchfile instead of stdin. Since it lacks user interaction it should be used in conjunction with non-interactive authentication. A batchfile of - may be used to indicate standard input. sftp will abort if any of the following commands fail: get, put, rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd and lmkdir. Termination on error can be suppressed on a command by command basis by prefixing the command with a - character (for example, -rm /tmp/blah*).
You could always have the tests and control external. If you have SFTP working, can you also SSH login to the same server as that account?
That would indeed work, except the only problem i have is that the server we send this to is a 3rth party server to which only sftp connection from our side is allowed.
On top of that the directory where we put the files (the only one we can put the files) has some service running on it that picks up the files and put them somewhere else. This pickup happens as soon as i put the file there. So i really need to be able to preform the check from my side only.
Another idea i have is to use
but i am currently testing this :-)
thx for the response but no solution yet.
---------- Post updated at 03:05 PM ---------- Previous update was at 02:50 PM ----------
Quote:
sftp rm should abort on fail, according to the man page:
i know. It is what I would have expected, only it continues as you can see in the output after i changed the rights on the files
Executing commandlist over sftp
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
I have a little code block (executing on AIX 7.1) that I cannot understand why the NOTFREE=0 does not appear to be assigned even though it goes through that block. This causes a unary operator issue.
#!/bin/bash
PLATFORM="AIX"
NEEDSPC=3000
set -x
if ; then
lsvg | grep -v rootvg | while... (6 Replies)
Hey all,
Here's my dilemma:
1. I'm a newbie at scripting!
2. I need to create a script that checks: If a file size is equal to zero, then stop the installation.
Is there a way to do this or am I wasting my time???
Thanx in advance! :b: (2 Replies)
Hi everyone,
I have this problem with a script I'm writting. I want to execute a code running in the background several times through a script. I am writting it like that
parent_script
for a in 1 2 3 4 5
do
exec test -n $a
done
What I want to do is when parent_script is killed,... (0 Replies)
Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
It is happening with my sessions already second time: a 'for'-loop for some reason stop to work as expected.
That means or it is looping without exitting, or it is not loop even once.
Here example of my try when it is not processing even one loop.
You can see, I start new subshell and... (14 Replies)
Hello everybody!
I am new to this and I am trying to change a script in an open source program that plots some offset vectors and then calls a postscript viewer. I have commented away the call for the postscript viewer but somehow the script doesn't return to the shell prompt. I cant figure out... (3 Replies)
Hi,
I am writing a bash shell script. How can I tell it to stop. For example, I would like to have something similar to the following:
mike=1
if ; then
STOP THE SCRIPT
fi (3 Replies)
Hi Folks,
I have been trying to create a script wherein after it reads a certain number of data, it will pause and ask the user if he wants to continue or not. However, it seems that when it is supposed to read the user's answer, the script will go into a loop. What is wrong with my script here?... (7 Replies)