Sponsored Content
Full Discussion: Linux Red Hat - FTP question
Top Forums Shell Programming and Scripting Linux Red Hat - FTP question Post 302394552 by maxshop on Thursday 11th of February 2010 10:56:26 PM
Old 02-11-2010
Linux Red Hat - FTP question

Hi Everyone,

Based on what I have read so far and what others have posted on this forum, I have come up with the following script to download and upload files from and to a FTP sever:

Code:
HOST=xyz.com
USER=someuser
PASSWD=somepwd

tmpfile=/tmp/files.$$

indir=/tmp/inbound
outdir=/tmp/outbound
inholddir=/tmp/inhold

ls $outdir/*.xml > $tmpfile 2>/dev/null

exec 4>&1
ftp -nv >&4 2>&1 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p ascii
print -p prompt off

if [[ -s $tmpfile ]]
then
  print -p cd Upload
  cat $tmpfile 2>/dev/null | while read xml_file
  do
    print -p put $xml_file
    rm -f $xml_file
  done
  print -p cd ..
fi

print -p cd Download
print -p lcd $inholddir
print -p mget *.xml
ls $inholddir/*.xml > $tmpfile 2>/dev/null
if [[ -s $tmpfile ]]
then 
  cat $tmpfile 2>/dev/null | awk -F "/" '{print $NF}' | while read xml_file
  do
    print -p delete $xml_file
    mv -f $inholddir/$xml_file $indir
  done
fi

rm -f $tmpfile

print -p bye
wait
exit 0

As you can see, after I perform "mget", I am trying to get a list of the XML files that were downloaded so that I can delete them from the remote FTP server and move them to the $indir on the local server. However, the "ls $inholddir/*.xml > $tmpfile 2>/dev/null" command generates no output even though files were sucessfully downloaded and are present in the $inholddir directory. I am not sure why. Can someone point me in the right direction?

Thanks!

PS: The reason I want to get a list of the downloaded files and then delete each file individually is because there is a possibility of new files appearing in the remote "Download" directory while the mget and/or the delete is in process (potential "timing" issue). In such cases, I don't want to delete files that have not been downloaded yet.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Red Hat Linux 6.0

Ok here is my problem i do not know the command to load a driver for my network card in Ted hat linux 6.0 could sombody give me a hand. and if there is anyone that has a list of commands for red hat that would be great also (2 Replies)
Discussion started by: bbutler3295
2 Replies

2. Shell Programming and Scripting

Trouble with FTP Linux red hat

Hi everyone, I Just finished installing Red Hat 7.1 server, and I am having a problem with FTP, and Telnet. I can FTP and Telnet to all client stations. But cannot FTP and Telnet to the server. Does any one know what i missed. All client hosts are in the etc/hosts already. (2 Replies)
Discussion started by: Link_02
2 Replies

3. UNIX for Dummies Questions & Answers

Red Hat 7.2 Linux Server - FTP Problems

I have just installed RH7.2 Server and along with apache 1.3 and PHP. I am able to FTP from my linux box to other remote maches, but am unable to FTP to the linux box from other remote machines. The message I get is: A remote host has refused an attempted connect operation. I have done some... (3 Replies)
Discussion started by: jyoung
3 Replies

4. Linux

Red-hat AS 2.1 network question

I have setup a AS 2.1 server with no X running or installed. I need to know how to configure the IP and such from command line and change it from DHCP. We used DHCP at first since we didn't know the IP we were going to use and now I need to change it. Any help would be great as Redhat's site just... (2 Replies)
Discussion started by: Acleoma
2 Replies

5. Linux

Red Hat Linux 9

Hello there! Will anybody please tell me some good links to online eBooks on Red Hat Linux 9 user experiences and the like. If the books are in PDF Format, it will be nice to read. Thanks for cooperation in advance. Enjoy using open source and breathe freely! JAM (5 Replies)
Discussion started by: Jawwad
5 Replies

6. Red Hat

Red Hat Linux release 9 (Shrike) question

Hi guys, wondering if you could help me out here... this is a proxy system problem I'm trying to access a web gui service off a linux box running Red Hat Linux release 9 (Shrike) used as a proxy server which does not seem to have a web browser installed..... how can i do this? so to... (2 Replies)
Discussion started by: slashbash
2 Replies

7. UNIX for Dummies Questions & Answers

how to know if i use "Red Hat Enterprise Linux" or "Red Hat Desktop" ?

how to know if i use "Red Hat Enterprise Linux" or "Red Hat Desktop" ? (2 Replies)
Discussion started by: ahmedamer12
2 Replies

8. Red Hat

Setting Up live FTP Server with Static IP in Red-Hat Linux 6

Hi Guys, I want to some guidance from you in setting up the Live FTP server in Redhat Linux 6 with Static IP 120.50.150.50. Now should I set my Static Public IP directly to my Linux machine? If so what whould be my sunbet mask? Is any type of natting required here? if so where would... (2 Replies)
Discussion started by: manalisharmabe
2 Replies

9. UNIX for Dummies Questions & Answers

Red Hat Linux question on top and vmstat outputs

RHEL 5.4 Our Linux machine seemed to be running slow. So, I ran the top and vmstat commands. Question1. I can see the process 11517 consuming 100% CPU . But that just means that this process totally utilizes one of the cores in a mult-core CPU. Right ? This machine apparently has two... (2 Replies)
Discussion started by: kraljic
2 Replies

10. Fedora

Which is the better platform to learn UNIX/Linux (Kali Linux Vs. Red Hat or other)?

I just started a new semester and I started my UNIX class yesterday. I've already decided to use python along with my learning process but what I really want to use with it is Kali as my UNIX/Linux platform to learn off of since I already wanted to learn Cyber Sec. anyways. I just wanted to know if... (12 Replies)
Discussion started by: ApacheOmega
12 Replies
ftpconfig(1M)						  System Administration Commands					     ftpconfig(1M)

NAME
ftpconfig - set up anonymous FTP SYNOPSIS
ftpconfig [ftpdir] ftpconfig -d ftpdir DESCRIPTION
The ftpconfig script is executed by the super user to set up anonymous FTP. Anonymous FTP allows users to remotely log on to the FTP server by specifying the user name ftp or anonymous and the user's email address as password. The anonymous users are logged on to the FTP Server and given access to a restricted file area with its own file system root. See chroot(2). The FTP area has its own minimal system files. This command will copy and set up all the components needed to operate an anonymous FTP server, including creating the ftp user account, creating device nodes, copying /usr/lib files, and copying timezone data. The passwd and group files set up have been stripped down to prevent malicious users from finding login names on the server. The anonymous file area will be placed under ftpdir. If the ftp user account already exists, then the current FTP area is used, and the system files in it are updated. All other files are left untouched. This command should be run to update the anonymous FTP area's configuration whenever a system patch is installed, or the system is upgraded. OPTIONS
-d Create a new or update an existing ftpdir without creating or updating the ftp user account. Use this option when creating guest FTP user accounts. OPERANDS
The following operands are supported: ftpdir The absolute pathname of the directory under which the anonymous FTP area is set up. EXIT STATUS
The following exit values are returned: 0 Successful completion 1 Improper usage of the command 2 Command failed ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWftpu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
ftpaddhost(1M), in.ftpd(1M), useradd(1M), chroot(2), attributes(5) SunOS 5.10 1 May 2003 ftpconfig(1M)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy