Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-17-2011
Registered User
 
Join Date: Jun 2010
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
SFTP check if file exists

I lookifn for a way to SFTP a file based on the presence of a flag file .

The logic is some thing like this in shelling terms

IF [[ ! -s file.DDMM.done ]]; then
download file.DDMM.dat
FI

The above is just the way of interpreting the logic.

Just want to add that i do not have SSh access to the remote server
Sponsored Links
    #2  
Old 10-17-2011
jayan_jay's Avatar
Forum Advisor
 
Join Date: Jul 2008
Posts: 831
Thanks: 9
Thanked 185 Times in 176 Posts
try this ..

Code:
if [ ! -s "file.DDMM.done" ]
then
        ftp -vin >> ftp.log <<!
        open remote_IP
        user $USER $PWD
        cd /path/in/remote/server
        get file.DDMM.dat
        bye
        !
else
        echo "File exists"
fi

Sponsored Links
    #3  
Old 10-22-2011
Registered User
 
Join Date: Jun 2010
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
i figured out a way to use batch file to check if the done file is there. i find is the file is there using the verbose mode of sftp. downside of using batch is that there will not be any return codes.

Well fo rnow it works . is there a better way ? would love to do it that way ..
Sponsored Links
Closed Thread

Tags
file exits, sftp script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
bash: check if file exists(without using if) gangsta Shell Programming and Scripting 3 10-07-2011 11:32 AM
Check to see if a file exists? buechler66 Shell Programming and Scripting 5 06-28-2011 10:38 PM
Check if file exists + ulp :S ruben.rodrigues Programming 2 02-22-2010 02:28 AM
FTP check if file exists and log it gseyforth Shell Programming and Scripting 1 08-12-2009 03:40 AM
check if remote file exists hcclnoodles Shell Programming and Scripting 2 08-27-2008 05:53 PM



All times are GMT -4. The time now is 05:27 AM.