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 > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Shell Script question ryanique Shell Programming and Scripting 10 08-26-2008 02:08 PM
Linux Shell Question: how to print the shell script name ? meili100 UNIX for Dummies Questions & Answers 3 07-01-2008 01:55 PM
Shell script question jbou1087 Shell Programming and Scripting 2 05-06-2008 02:01 AM
shell script question tselvanin Shell Programming and Scripting 2 08-28-2007 09:53 PM
A shell script question surjyap Shell Programming and Scripting 2 11-24-2005 05:48 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 09-01-2008
bsandeep_80 bsandeep_80 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 122
FTP - shell script question

Hi All,

I had a question on something which i have trying to add to my current shell script which does FTP of files from my local machine to a remote server.

I have 5 files which i zip and FTP them on daily basis to a remote server. My script is as below:
############################
#!/bin/sh
temp="put $1"
ftp xxxx.this is IP address of remote machine.com << EOFFile
myusername
binary
$temp
quit
EOFFile
exit 0
############################

I am successfull in doing this activity.

But sometimes there is some problem with the remote FTP machine the FTP fails.

My problem is that i am only able to determine this failure after manually logging in checking for the files on remote machine.

My remote files look like this on FTP machine, all the files have the same name each day and The system date of this matches with the local machine:

08-31-08 10:00PM 55182 help1.zip
08-31-08 10:00PM 64861 help2.zip
08-31-08 10:00PM 57915 help3.zip
08-31-08 10:01PM 224245 help4.zip
08-31-08 10:01PM 2388 help5.zip


Is there a way i can add in my script or have an external script that checks for these files on FTP machine( probablly compare with local machine date stamp and FTP date stamp to determine the latest files are there).

Please suggest

Thanks,
Sandy
  #2 (permalink)  
Old 09-01-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 596
One option shoud be ..

After copying files to remote server, just before quit the connection, give a ls and capture it in a shell variable.Then, verify the files list from the variable...

ie,

Code:
var=$(ftp xxxx.this is IP address of remote machine.com << EOFFile 
......
...
lcd
ls
quit
EOFfile
)

echo $var
  #3 (permalink)  
Old 09-02-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
The ftp command is designed for interactive use.

For scripts, use the ncftp group of commands, or, if possible, use scp.
  #4 (permalink)  
Old 09-03-2008
bsandeep_80 bsandeep_80 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 122
Hi dennis,

#!/bin/sh
var=$(ftp www.state.il.us << EOFFile
symphems
binary
ls
quit
EOFfile
)

This gives me the required results but the results of echo $var is as below:
11:52PM 61954 help1.zip 09-02-08 10:01PM 8153 help2.zip 09-02-08 10:01PM 1890 help3.zip

The results are in a single line.

Can you please help how i can have them one fter another.

Thanks,
Sandy
  #5 (permalink)  
Old 09-03-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 596
Quote:
Originally Posted by bsandeep_80 View Post
Hi dennis,

#!/bin/sh
var=$(ftp www.state.il.us << EOFFile
symphems
binary
ls
quit
EOFfile
)

This gives me the required results but the results of echo $var is as below:
11:52PM 61954 help1.zip 09-02-08 10:01PM 8153 help2.zip 09-02-08 10:01PM 1890 help3.zip

The results are in a single line.

Can you please help how i can have them one fter another.

Thanks,
Sandy

Assuming that you have only zip files in the location:

Code:
echo $var | sed 's/zip/zip\n/g'
or

Code:
echo $var | xargs -n4
  #6 (permalink)  
Old 09-03-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by bsandeep_80 View Post
This gives me the required results but the results of echo $var is as below:
11:52PM 61954 help1.zip 09-02-08 10:01PM 8153 help2.zip 09-02-08 10:01PM 1890 help3.zip

The results are in a single line.

Can you please help how i can have them one fter another.

Quote your variables:

Code:
echo "$var"
  #7 (permalink)  
Old 09-09-2008
bsandeep_80 bsandeep_80 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 122
Thanks dennis

regards,
Sandy
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 04:37 PM.


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