Transfert file with scp (ssh)
Transfert file with scp (ssh)
am 08.11.2007 22:42:58 von Rahan
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 help me please.
Thanks a lot for your help
Best Regards
Rahan
Re: Transfert file with scp (ssh)
am 08.11.2007 23:11:28 von Icarus Sparry
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
Re: Transfert file with scp (ssh)
am 09.11.2007 19:40:22 von Claudio
On 2007-11-08, 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.
scp file remote-machine:path/
while [ $0 -ne 0 ]; do
sleep 60
scp file remote-machine:path/
done
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
Re: Transfert file with scp (ssh)
am 09.11.2007 20:00:48 von cfajohnson
On 2007-11-09, Claudio wrote:
> On 2007-11-08, Rahan 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.
>
>
> scp file remote-machine:path/
> while [ $0 -ne 0 ]; do
> sleep 60
> scp file remote-machine:path/
> done
>
>
> 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
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
Re: Transfert file with scp (ssh)
am 09.11.2007 20:13:58 von gazelle
In article ,
Claudio wrote:
>On 2007-11-08, 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.
>
>
>
>scp file remote-machine:path/
>while [ $0 -ne 0 ]; do
> sleep 60
> scp file remote-machine:path/
>done
>
>
>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) ?
Re: Transfert file with scp (ssh)
am 09.11.2007 20:54:52 von Claudio
On 2007-11-09, Chris F.A. Johnson wrote:
> On 2007-11-09, Claudio wrote:
>> On 2007-11-08, Rahan 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.
>>
>>
>> scp file remote-machine:path/
>> while [ $0 -ne 0 ]; do
>> sleep 60
>> scp file remote-machine:path/
>> done
>>
>>
>> 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.
scp name-of-file machine:path
while [ $? -ne 0 ]; do
echo cannot copy. Waiting...
sleep 300
scp name-of-file machine:path
done
Best regards,
Claudio.
Re: Transfert file with scp (ssh)
am 11.11.2007 20:44:20 von Rahan
Hello and thanks to all for your answers.
Cdlt
Rahan