LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Check to see source server is available (https://www.linuxquestions.org/questions/linux-newbie-8/check-to-see-source-server-is-available-656135/)

irfanb146 07-16-2008 09:25 AM

Check to see source server is available
 
Hi,
I am using following to copy file from one server to other in a script but before using this command i want to use another command to check whether source server is accissable or not.

Command is running from destination server

scp -p source:/home/msl/abc1.csv /home/destination_folder

Vit77 07-16-2008 09:55 AM

The easiest variant is:
Code:

ping -c 1 HOST | grep -q '1 received'
if [ $? -eq 0 ]
then
  scp...
fi


chrism01 07-16-2008 10:52 PM

That only checks the network stack is up, not whether scp will work. Do it in arrears like this

Code:

scp -p source:/home/msl/abc1.csv /home/destination_folder
if [[ $? -ne 0 ]]
then
    echo "scp failed"
    exit 1
fi


irfanb146 07-17-2008 08:03 AM

Thanks for your help


All times are GMT -5. The time now is 11:20 PM.