FTP connection, uploading and downloading files through Shell between unix and linux
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
FTP connection, uploading and downloading files through Shell between unix and linux
Dear All,
I am actually an Oracle DBA, trying my hand on some of the shell scripting, to ensure that some of the manual tasks my developers do, are removed from their hectic responsibilities.
They generate a file (a flat file of encoding type ANSI) through Oracle (which is based on a HP Unix box) on a NAS Server running on windows, so I pick it from there, load it onto Linux convert the char-set to UTF8 and push it back to the NAS, so that they can have it as UTF8 as desired.
If not this, the developers have to open each file in Windows manually and "save-as" UTF8 encoding, and the files are huge and in huge number
Everything in my shell code works in bits (individually), except for the main connection, how do I connect from my Linux to HP Unix using ftp and mput, mget and delete files.
for instance,
My red hat linux box is having this code
ftp -vnd "11.11.11.11" <<++ 1>>readme.log 2>&1
user "username" "password"
prompt off
binary
prompt
lcd /backup/data
mget *
find /backup/data/ -name '*'\.\txt -type f -print|while read FILENAME
do
ls -altr "${FILENAME}" >> /backup/data/files.log
iconv -f windows-1256 -t UTF-8 "${FILENAME}" > "${FILENAME%.txt}_utf8.txt"
done
bye
But my connection is hanging for endless feeds from user, leave everything else coming after it.
1. I'm confused about several things in the snippet you gave. For example, if you use a "here document" (like "ftp << EOF"), then I would expect to see a corresponding "EOF" at the end of the file. Here's what I mean about "here documents" (pun intended ;-)): http://tldp.org/LDP/abs/html/here-docs.html
Each different ftp client supports different options, and has different limitations. For example, "ftp" on Solaris might behave quite differently from "ftp" on HP-UX.
3. Finally, perhaps you might not need to script anything at all. Have you considered NFS-mounting the NAS on HP-UX (or using Samba to mount a Windows share on HP-UX)? Just a thought...
Sorry for the ambiguity. My purpose is to create a shell script on a RHAS box, which will run regularly and connect to a HP Unix Source through FTP and get files from there. I saw the links, but maybe because of me a "newnewbie" to the Linux world, it did not work for me. Should I be creating a file "conn.sh", which would pull commands from ftp_commands.lst. A similar thing in windows worked for me, but not here I guess.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.