The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > IP Networking
.
google unix.com



IP Networking Learn TCP/IP, Internet Protocol, Routing, Routers, Network protocols in this UNIX and Linux forum.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Checking availability of Web pages through Unix script srivsn Shell Programming and Scripting 6 05-30-2007 08:57 AM
Transfer file from local unix server to remote server indira Shell Programming and Scripting 2 05-03-2007 06:35 AM
Transfer file from local unix server to remote server indira HP-UX 2 05-02-2007 05:15 PM
Checking for availability of remote server dylanmilks Shell Programming and Scripting 4 03-01-2007 12:08 PM
FTP multiple files from remote server to local server berlin_germany Shell Programming and Scripting 2 12-20-2006 03:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-22-2007
dylanmilks dylanmilks is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 4
Checking for availability of remote server

Hi. In my KSH script I'm running a command on a remote server. I want to know how I can test to see if the remote server is available (accessible) prior to running the command. Any ideas?

My command looks like:

`ssh $USER@$TARGET_SERVER_DNS ls -l $REMOTE_FOLDER `

This check should be generic enough to handle the following cases:

- server not available (network problem)
- server DNS name not found
- invalid user name, user doesn't exist on the remote server
- remote folder path doesn't exist
- etc

I just need for the SSH command to return a true/false indicating success or failure, that's it.

One inportant point: PING is disabled in my environment.
  #2 (permalink)  
Old 02-22-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
As a general rule, if a command does not return an exit status of 0, it means that something failed. I tried out the first four of your scenarios, and ssh returns 255 for the first three error conditions, and returns 2 (file not found) if the remote directory does not exist.

Simply put, check for the return values for the ssh command.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0