- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: FTP to multiple systems from a script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 09:13 AM
10-02-2002 09:13 AM
I am trying to figure out how i would be able to accomplish an FTP to 2 or more systems from within the same script, each time I do it, it will only go to the 1st system and then when it hits the next system it tells me that the user is already logged in and fails.
Any clues?
#! /usr/bin/ksh -v
# Environmental section
DATE=`date +%m/%d/%Y`
SCRIPT_SYSTEM=$(uname -n)
DEST06=mmdcux06.chsli.org
DEST10=mmdcux10.chsli.org
USER=fgrosb01
PW=poolgod1
REMOTECD=/tmp
LOCALCD=/home/fgrosb01/syslogproject/messagesfiles
OUTPUT_FILE=/home/fgrosb01/syslogproject/messages_systems
MAIL=/usr/bin/mailx
ADDRESS=frank.grosberger@chsli.org
#! /usr/bin/ksh -v
# Environmental section
DATE=`date +%m/%d/%Y`
SCRIPT_SYSTEM=$(uname -n)
DEST06=mmdcux06.chsli.org
DEST10=mmdcux10.chsli.org
USER=fgrosb01
PW=
REMOTECD=/tmp
LOCALCD=/home/fgrosb01/syslogproject/messagesfiles
OUTPUT_FILE=/home/fgrosb01/syslogproject/messages_systems
MAIL=/usr/bin/mailx
ADDRESS=frank.grosberger@chsli.org
# This section will perform a series of FTP's to each system then taking
# the file located on each system and bringing it back to the local
# collection station system.
ftp -n -v ${DEST06} << EOF
user ${USER} ${PW}
binary
lcd ${LOCALCD}
cd ${REMOTECD}
get messages.mmdcux06
chmod 600 messages.mmdcux06
sleep 30
ftp -n -v ${DEST10} << EOF
user ${USER} ${PW}
binary
lcd ${LOCALCD}
cd ${REMOTECD}
get messages.mmdcux10
chmod 600 messages.mmdcux10
quit
sleep 30
# This section takes each of the files that have been FTP'd from each
# system and will concatenate them into one file for single viewing
cat /dev/null > ${OUTPUT_FILE}
cd /home/fgrosb01/syslogproject/messagesfiles
for i in `ls`
do
echo "****************************************************" >>${OUTPUT_FILE}
echo Contents of $i >> ${OUTPUT_FILE}
cat $i >>${OUTPUT_FILE}
echo "End of report" >> ${OUTPUT_FILE}
echo "****************************************************" >>${OUTPUT_FILE}
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 09:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 09:35 AM
10-02-2002 09:35 AM
Re: FTP to multiple systems from a script
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 09:38 AM
10-02-2002 09:38 AM
Re: FTP to multiple systems from a script
after your first file transfer completes, go ahead and get rid of the sleep 30 and replace with:
disconnect # this will drop the ftp link to server1
open ${DEST10} # this will open ftp to new server
now delete your second ftp command.. you don't need this and this is what is complaining... it means you already have an ftp session active.
now you should be in business assuming the rest of the script is clean... I built a small script with your syntax using these changes and it worked.
Ted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 11:25 AM
10-02-2002 11:25 AM
Re: FTP to multiple systems from a script
I made the changes that each of you specified.
Now what is happening is that the script will
run thru both FTP's successfully but the script
will terminate at the end of the 2nd FTP
without hitting the section that takes the
files and combines them.
I tried putting combinations of CLOSE, quit,
or DISCONNECTS to end the FTP with no
success.
Any ideas?
#! /usr/bin/ksh -v
# Environmental section
DATE=`date +%m/%d/%Y`
SCRIPT_SYSTEM=$(uname -n)
DEST06=mmdcux06.chsli.org
DEST10=mmdcux10.chsli.org
USER=fgrosb01
PW=poolgod1
REMOTECD=/tmp
LOCALCD=/home/fgrosb01/syslogproject/messagesfiles
OUTPUT_FILE=/home/fgrosb01/syslogproject/messages_systems
MAIL=/usr/bin/mailx
ADDRESS=frank.grosberger@chsli.org
# This section will perform a series of FTP's to each system then taking
# the file located on each system and bringing it back to the local
# collection station system.
ftp -n -v ${DEST06}<< EOF
user ${USER} ${PW}
binary
lcd ${LOCALCD}
cd ${REMOTECD}
get messages.mmdcux06
chmod 600 messages.mmdcux06
disconnect
open ${DEST10}
user ${USER} ${PW}
binary
lcd ${LOCALCD}
cd ${REMOTECD}
get messages.mmdcux10
chmod 600 messages.mmdcux10
disconnect
close ${DEST10}
# This section takes each of the files that have been FTP'd from each
# system and will concatenate them into one file for single viewing
cat /dev/null > ${OUTPUT_FILE}
cd /home/fgrosb01/syslogproject/messagesfiles
for i in `ls`
do
echo "****************************************************" >>${OUTPUT_FILE}
echo Contents of $i >> ${OUTPUT_FILE}
cat $i >>${OUTPUT_FILE}
echo "End of report" >> ${OUTPUT_FILE}
echo "****************************************************" >>${OUTPUT_FILE}
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 08:58 PM
10-02-2002 08:58 PM
Re: FTP to multiple systems from a script
ftp -n -v << EOF
...
...
close ${DEST10}
EOF
# This section takes each of the files that have been FTP'd from each
# system and will concatenate them into one file for single viewing
....
....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2002 03:20 AM
10-03-2002 03:20 AM
Re: FTP to multiple systems from a script
The EOF should be there before the cat command.
Modify your script as below.
ftp -n -v ${DEST06}<< EOF
...
close ${DEST10}
EOF
cat /dev/null > ${OUTPUT_FILE}
...
Hope this helps.
-balaji