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 > 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-21-2008 12:10 AM
automate Telnet ? tbeghain Shell Programming and Scripting 4 06-19-2007 06:09 AM
How to automate an FTP process? ksak Shell Programming and Scripting 1 10-06-2006 12:45 PM
How to automate responses djp Shell Programming and Scripting 2 06-07-2005 04:00 PM
Automate FTP CamTu UNIX for Advanced & Expert Users 4 02-25-2005 10:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-22-2002
flowrats
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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.
  #2 (permalink)  
Old 07-22-2002
hassan2 hassan2 is offline Forum Advisor  
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 Forum Advisor  
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
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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
Bits: 0 [Banking]
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
Bits: 0 [Banking]
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
Bits: 0 [Banking]
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
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 06:43 AM.


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