![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automate FTP | borncrazy | Shell Programming and Scripting | 11 | 02-20-2008 08:10 PM |
| automate Telnet ? | tbeghain | Shell Programming and Scripting | 4 | 06-19-2007 03:09 AM |
| How to automate an FTP process? | ksak | Shell Programming and Scripting | 1 | 10-06-2006 09:45 AM |
| How to automate responses | djp | Shell Programming and Scripting | 2 | 06-07-2005 01:00 PM |
| Automate FTP | CamTu | UNIX for Advanced & Expert Users | 4 | 02-25-2005 06:08 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
I am trying to write and automate a ftp job that connects to a IBM mainframe and pulls the same files everyday. To do this I assumen I create a .netrc file in my solaris home directory, then I write a shell script. How do I envoke ftp from a ksh script and pass it the info in .netrc? I have tried several examples listed on this site, but they all terminate in errors. One problem is the the mainframe files are in the format '111.111.33.333.333' and when I put \'111.111.33.333.333\' in the script I get a SCCS error. Any idea on how to simply get 5 files every day, filenames that never change? Thanks. |
| Forum Sponsor | ||
|
|
|
|||
|
Try
#!/usr/bin/ksh ftp -v -n "ibm mainframe ip address" user "user" "passwd" cd /mainframe directory lcd /my local_unix directory bin mget 111.111.33.333.333 bye Note: mget will get a bunch of files . Do a man mget for more information |
|
||||
|
I'm not sure what you mean when you write
Quote:
Can you post your script? If not, this link may help - Look for Question 8 |
|
|||
|
I am not sure what you've done already but
this is how you can do it in a ksh script, variable names are arbitrary: if [ $? -eq 0 ]; then # Create a .netrc file echo "machine $IBMNODE" > $HOME/.netrc chmod 600 $HOME/.netrc echo "login $USERID password $PSWD">> $HOME/.netrc echo "macdef init" >> $HOME/.netrc echo "prompt" >> $HOME/.netrc echo "lcd $HOME/mylocaldir/" >> $HOME/.netrc echo "bin" >> $HOME/.netrc #if need echo "get 111.111.222.33" >> $HOME/.netrc echo "get 111.222.222.33" >> $HOME/.netrc echo "get 111.333.222.33" >> $HOME/.netrc echo "get 111.444.222.33" >> $HOME/.netrc echo "get 111.555.222.33" >> $HOME/.netrc echo "quit" >> $HOME/.netrc echo "\n" >> $HOME/.netrc echo "`date +%T` N"\ "Successfully set up the .netrc" >> $MYLOG echo "`date +%T` N"\ "FTPing to remote host..." >> $MYLOG ftp -v $IBMNODE >| $TEMPFTPLOG 2>&1&& cat $TEMPFTPLOG >> $PERMFTPLOG&& # check status of ftp execution... if [[....etc]] s/t ..page support else s/t fi ... ftp -v is verbose. As long as you are ftping to $IBMNODE (.netrc value matches the ftp command), it will be automatic. ... hope this makes sense. Gianni |
|
|||
|
Automatic ftp job
Gianni,
Thanks for the script. I assume that if I have already created a .netrc file and set it to 600 that I do not need the first four lines. When I modifiy the file with the actual names of the mainframe files, and run your script, the I get the error: "error line 21 '|' unexpected" so I modified the line 21 from: ftp -v $IBMNODE >| $TEMPFTPLOG 2>&1&& to ftp -v $IBMNODE > $TEMPFTPLOG 2>&1&& and I remove the lines from: #check status of ftp execution... to the end of the script, I get another error "end of file unexpected" Thanks. |
|
|||
|
RTM,
I guess the best way to put it is that the format of the file is text format, but the file discriptor (name of the file) begins and ends with a single quote, and has decimials in the name. So I assume that when I get the file I have to use the ecape charator, unlike I would manually to get a file with a quote in it: manualy I would type get '111.222.333.444.555' but in a script I would type: get \'111.222.333.444.555\' flowrats |
|||
| Google UNIX.COM |