![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check if file exists on remote system ? | hcclnoodles | Shell Programming and Scripting | 2 | 10-26-2006 04:08 AM |
| Need Script to check whether user exists in the remote machine | Srini75 | SCO | 1 | 09-07-2005 11:23 AM |
| check if exists a .ZIP file and unzip it using ftp | DebianJ | Shell Programming and Scripting | 1 | 05-05-2005 04:46 PM |
| Check Remote Folder Exists | borncrazy | Shell Programming and Scripting | 1 | 07-12-2004 04:15 PM |
| perl ftp check file exists | methos | Shell Programming and Scripting | 2 | 06-18-2003 08:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
check if remote file exists
Hi
Does anybody know how I can check if a file exists on a remote machine i.e. see bellow, this doesn't work by the way and if tried countless variations on this Code:
#!/bin/sh hostname=server56 if [ -f `ssh $hostname '/usr/local/file'` ]; then echo file exists else echo file doesn't exist fi |
|
||||
|
Here's another way:
Code:
#!/bin/sh
#
# Name:
# testfile
#
# Usage:
# ./testfile "/dir/and file to test for.txt"
#
# Notes:
# Quotes needed when testing for names with whitespace, etc.
# Be certain to:
# > chmod 700 testfile
# and perform any setup needed for ssh such as key generation and
# proper placment on the remote computer
#
hostname=mike@ram
echo $hostname
if ssh $hostname 'ls "'$1'" >/dev/null'; then
echo "file '"$1"' exists";
echo "byebye";
exit;
else
echo "file '"$1"' doesn't exist";
fi
echo "finito!"
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|