LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-16-2008, 09:25 AM   #1
irfanb146
LQ Newbie
 
Registered: Mar 2008
Posts: 19

Rep: Reputation: 0
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
 
Old 07-16-2008, 09:55 AM   #2
Vit77
Member
 
Registered: Jun 2008
Location: Toronto, Canada
Distribution: Mandriva, RHEL, Mageia, SuSE
Posts: 130

Rep: Reputation: 17
The easiest variant is:
Code:
ping -c 1 HOST | grep -q '1 received'
if [ $? -eq 0 ]
then
  scp...
fi
 
Old 07-16-2008, 10:52 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,280

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
 
Old 07-17-2008, 08:03 AM   #4
irfanb146
LQ Newbie
 
Registered: Mar 2008
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks for your help
 
  


Reply

Tags
check, scp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
check out source from SBLIM CVS nodar Linux - Newbie 1 12-16-2007 12:56 PM
Health Check / Server Completion Check Software? tells Linux - Enterprise 0 04-20-2006 11:03 AM
from source/dependency check TheBman Linux - Software 1 12-30-2003 02:22 AM
Topsecret!!! Source Code!!!! Check This Out!!! 320mb General 6 12-15-2003 06:11 AM
how to check if kernel source is installed ? xprometeus Linux - Software 4 10-09-2003 07:18 PM


All times are GMT -5. The time now is 03:01 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration