FTP run from shell script gives slow transfer rates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP run from shell script gives slow transfer rates
# 1  
Old 04-07-2009
FTP run from shell script gives slow transfer rates

Hey everybody, this is my first post so be gentle. I have two Sun 5220's running Solaris 10 that are directly connected with a cross-over cable at Gig. One of these boxes is my production Oracle server which generates a 50GB dump file every evening at 10:50. The other Solaris is a devolopment server that is identical to the production. While they are attached to the network using IPMP and two of the NICs, I have 1 extra NIC dedicated to this private network between boxes. I am trying to script the FTP transfer between servers.

Here is the issue. When I run FTP interactively from Server A (prod) and do a put, I can transfer the file in 35 minutes or so. However when i run the same FTP commands in a shell script takes 5-7 hours to complete. I have thought maybe this is a priority issue and have looked at NICE, but I am kind of scared to mess with processor priority on my production database server.

Here is my script with then names changed to protect the innocent. I run this script from Server A (prod). It is pretty straight forward, so I really don't think their is a problem with the code. Something is causing it run 10 times slower when run from a script. Thanks in advance to anyone who can help me here.

#!/bin/sh
HOST="192.168.1.2"
USER="user"
PASSWD="passwd"

cd /u14/exp

ftp -in $HOST <<END_FTP
quote USER $USER
quote PASS $PASSWD
cd /u11/exp
put file.dmp
quit
END_FTP
EOF
# 2  
Old 04-07-2009
I don't see any problem except the last line....If that's not the problem hopely someone else can shed some lights on this.

Regards
# 3  
Old 04-07-2009
Thanks

Maybe I should have posted this in the Solaris forum. Like I said I don't think it is the script itself, but rather how Solaris is prioritizing the ftp process when called from a shell script. I have been stuck for two days on this and have worn out the Google in search of an answer. I bet it is something really simple, but it is kicking my tail right now.
# 4  
Old 04-07-2009
everything looks kosher to me.
you cat try adding 'set -x' in your script to see what's actually taking place - like is your script's "ftp" the same as your command line - strange things do happen.
Also you can add 'hash' to your ftp session to see the progress of the transfer. And do the same to your command line - then may be compare (first just visually) the rates.The 'rates' might be the same, but the script may be hanging at the end somehow - a wild guess...

I assume both things (CLI and script) use the same FTP port (22)...

Others may chime in as well.
# 5  
Old 04-07-2009
When I run the script or run ftp manually, I have a PuTTY session open to the destination server and directory so that I can see the progress. From the script it takes approximately 6 minutes to transfer 1GB of data. When run interactively 1GB transfers in about 40 seconds.

Everything should be the same. FTP works from the script, it just behaves like it has been throttled. One more thing I thought of, our production server runs a script every 3 minutes during the first 10 days of the month that polls for ftp connections where data files are being submitted by our customers. I wonder if the previous admin (who did not document anything Smilie) added something to the config which is throttling the bandwidth on non-interactive ftp connections?

What exactly does set-x do? I am pretty green, but I am catching on fast. I was a Windoze AD and Exchange admin for 10 years before I got this job and have been in the UNIX world for about 6 months.

Last edited by Countificus; 04-07-2009 at 05:31 PM..
# 6  
Old 04-07-2009
Quote:
Originally Posted by Countificus
When I run the script or run ftp manually, I have a PuTTY session open to the destination server and directory so that I can see the progress. From the script it takes approximately 6 minutes to transfer 1GB of data. When run interactively 1GB transfers in about 40 seconds.

Everything should be the same. FTP works from the script, it is just like it has been throttled. One more thing I thought of, our production server runs a script every 3 minutes during the first 10 days of the month that polls for ftp connections where data files are being submitted by our customers. I wonder if the previous admin (who did not docuemnt anything Smilie) added something to the config which is throttling the bandwidth on non-interactive ftp connections?
Not sure if it's possible, but then again I have not done much with the ftpd myself.
One thing from 'man ftpd' (on Solaris) kinda caught my eye:
Code:
     -X    Write the output from the -i and  -o  options  to  the
           syslogd(1M)  file  instead  of xferlog(4). This allows
           the collection of output from  several  hosts  on  one
           central  loghost.  You  can  override  the  -X  option
           through use of the ftpaccess(4) file.

maybe there's an extensive logging going on with the '-i' option that you have in your script and don't have with the cli.
Quote:
Originally Posted by Countificus
What exactly does set-x do? I am pretty green, but I am catching on fast. I was a Windoze AD and Exchange admin for 10 years before I got this job and have been in the UNIX world for about 6 months.
'set -x' will output ALL the commends from the script as they're to be executed - this is a shell's debugging mechanism.
# 7  
Old 04-07-2009
As an alternative, you could use scp (secure copy) rather than ftp to transfer the files. SCP does not require USER or PASS arguments, which may be causing part of your problem.

I use this to copy between production and DR. It is secure, and it is encrypted.

There is some background configuration for SSH that you will need to do beforehand, but I believe you can find that fairly easily without 'wearing out' Google Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script reading file slow

I have shell program as below #!/bin/sh echo ======= LogManageri start ========== #This directory is getting the raw data from remote server Raw_data=/opt/ftplogs # This directory is ready for process the data Processing_dir=/opt/processing_dir # This directory is prcoessed files and... (4 Replies)
Discussion started by: Chenchireddy
4 Replies

2. UNIX for Dummies Questions & Answers

To run ksh script via autosys job without asking password for file transfer

I've K shell script. It will transfer the files from one server to other server using 'SCP' command. While running the script alone as a command line in UNIX ssh terminal its running with out asking password and files are transferred with out asking for password. But by running the script using... (6 Replies)
Discussion started by: maheshbabu
6 Replies

3. Shell Programming and Scripting

Shell Scripting for creating ftp and transfer file

Dear All, We run backup script to update backup file every hour. I want to create a script, which transfer these files in another server using ftp as new backup file created every hour. Files should be stored with a unique name for every hour(e.g 20130708_13:00 , 20130708_14:00 and so on) and... (13 Replies)
Discussion started by: Preeti Saini
13 Replies

4. Shell Programming and Scripting

How to run a shell script on a remote host using ftp

Hi, is there a way I can run a shell script through ftp on a remote host? The remote host doesn't have ssh running so I can't use ssh. (7 Replies)
Discussion started by: mrskittles99
7 Replies

5. Windows & DOS: Issues & Discussions

to run shell script using FTP

Hi All, From FTP prompt, How to run Unix Shell scripts? Thanks in Advance, (1 Reply)
Discussion started by: HemaV
1 Replies

6. UNIX for Dummies Questions & Answers

Very SLOW STFTP transfer rate

Hi, I am experiencing extremely show transfer rates when transferring zip files over SFTP. Over FTP it works fine. I have disabled compression in the sshd_config file but that does not seem to help.. Any ideas? (0 Replies)
Discussion started by: mojoman
0 Replies

7. Shell Programming and Scripting

RSYNC script to transfer folders recursively without overwriting via FTP

Hi all, I would need a bash script to sync/transfer folders recursively via FTP/RSYNC (I initially planned to use FTP but I heard RSYNC would fit a lot better for this job(?)) The situation: 3 different Linux servers 1. source 2. destination - Samba 3. Server where the script runs on ... (2 Replies)
Discussion started by: thibautp
2 Replies

8. Shell Programming and Scripting

Script for FTP (transfer only new files)

Hi everybody, I just want to transfer files with FTP (mget and mput). The problem is that I dont want to overwrite any existing files and don't want to transfer them again (e.g. using the rename-function). So I only want to transfer new files with mget and mput. My first idea was to create... (3 Replies)
Discussion started by: inoxx
3 Replies

9. UNIX for Advanced & Expert Users

script to be run after every FTP transfer

Hello everyone, we are running VSFtpd as FTP Server on Redhat AS 5. I would like to have a script to be run immediately after every FTP transfer. Is is possible (or with any other FTP Server?). I thought of writing a script to monitor if FTP transfer happening and run the required-script... (2 Replies)
Discussion started by: prvnrk
2 Replies
Login or Register to Ask a Question