|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello everybody,
Every day, i need to transfert 1 file from one to another solaris server by using scp (ssh). i am looking a script or an exemple of the script to do it by first checking the presence of the file, and then, transfert it and re-transfert it if the transfert fails for some raison like a network problem or remote host down. Sorry, i am beginner, could you me please. Thanks a lot for your Best Regards Rahan |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Thu, 08 Nov 2007 22:42:58 +0100, Rahan wrote:
> Hello everybody, > > Every day, i need to transfert 1 file from one to another solaris server > by using scp (ssh). > > i am looking a script or an exemple of the script to do it by first > checking the presence of the file, and then, transfert it and > re-transfert it if the transfert fails for some raison like a network > problem or remote host down. while ! ssh otherhost test -f filename do scp filename otherhost:. || sleep 60 done |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2007-11-08, Rahan <Rahan@rahan.net> wrote:
> Hello everybody, > > Every day, i need to transfert 1 file from one to another solaris server > by using scp (ssh). > > i am looking a script or an exemple of the script to do it by first > checking the presence of the file, and then, transfert it and > re-transfert it if the transfert fails for some raison like a network > problem or remote host down. <untested> scp file remote-machine:path/ while [ $0 -ne 0 ]; do sleep 60 scp file remote-machine:path/ done </untested> I think it's understandable. $0 is the return value of the last command. By convention, it equals 0 if everything was ok. Best regards, Claudio |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 2007-11-09, Claudio wrote:
> On 2007-11-08, Rahan <Rahan@rahan.net> wrote: >> >> Every day, i need to transfert 1 file from one to another solaris server >> by using scp (ssh). >> >> i am looking a script or an exemple of the script to do it by first >> checking the presence of the file, and then, transfert it and >> re-transfert it if the transfert fails for some raison like a network >> problem or remote host down. > ><untested> > scp file remote-machine:path/ > while [ $0 -ne 0 ]; do > sleep 60 > scp file remote-machine:path/ > done ></untested> > > I think it's understandable. $0 is the return value of the > last command. By convention, it equals 0 if everything was ok. I think you mean $? not $0. -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
In article <slrnfj9acm.hp8.claudio@example.org>,
Claudio <claudio@example.org> wrote: >On 2007-11-08, Rahan <Rahan@rahan.net> wrote: >> Hello everybody, >> >> Every day, i need to transfert 1 file from one to another solaris server >> by using scp (ssh). >> >> i am looking a script or an exemple of the script to do it by first >> checking the presence of the file, and then, transfert it and >> re-transfert it if the transfert fails for some raison like a network >> problem or remote host down. > > ><untested> >scp file remote-machine:path/ >while [ $0 -ne 0 ]; do > sleep 60 > scp file remote-machine:path/ >done ></untested> > >I think it's understandable. $0 is the return value of the >last command. By convention, it equals 0 if everything was ok. Which shell are you using (where $0 is the return value) ? |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 2007-11-09, Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
> On 2007-11-09, Claudio wrote: >> On 2007-11-08, Rahan <Rahan@rahan.net> wrote: >>> >>> Every day, i need to transfert 1 file from one to another solaris server >>> by using scp (ssh). >>> >>> i am looking a script or an exemple of the script to do it by first >>> checking the presence of the file, and then, transfert it and >>> re-transfert it if the transfert fails for some raison like a network >>> problem or remote host down. >> >><untested> >> scp file remote-machine:path/ >> while [ $0 -ne 0 ]; do >> sleep 60 >> scp file remote-machine:path/ >> done >></untested> >> >> I think it's understandable. $0 is the return value of the >> last command. By convention, it equals 0 if everything was ok. > > I think you mean $? not $0. > Ops! sure. My mistake. I'm very sorry. <tested> scp name-of-file machine:path while [ $? -ne 0 ]; do echo cannot copy. Waiting... sleep 300 scp name-of-file machine:path done </tested> Best regards, Claudio. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Hello and thanks to all for your answers.
Cdlt Rahan |
|
![]() |
| Outils de la discussion | |
|
|