The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-22-2002
flowrats
Guest
 

Posts: n/a
Angry automate an ftp job

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
  #2 (permalink)  
Old 07-22-2002
Registered User
 

Join Date: Mar 2002
Location: London, England
Posts: 262
Wink

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
  #3 (permalink)  
Old 07-22-2002
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
I'm not sure what you mean when you write

Quote:
files are in the format '111.111.33.333.333'
Your script should not care about the format of the file. You should put in the type (ascii or bin). If the file is ebcdic, you may have to change it before or after doing the ftp.

Can you post your script?

If not, this link may help - Look for Question 8
  #4 (permalink)  
Old 07-22-2002
Registered User
 

Join Date: Sep 2001
Location: Phoenix
Posts: 76
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
  #5 (permalink)  
Old 07-23-2002
flowrats
Guest
 

Posts: n/a
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.
  #6 (permalink)  
Old 07-23-2002
flowrats
Guest
 

Posts: n/a
hassan2,

When I run your script, It gets me logged onto the mainframe, but does not execute the four lines of the script until after I manually quit from ftp.

flowrats
  #7 (permalink)  
Old 07-23-2002
flowrats
Guest
 

Posts: n/a
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
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0