Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 02-16-2009, 01:17 AM   #1
LQ Newbie
Registered: Feb 2009
Posts: 5

Rep: Reputation: 0
Unhappy 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 "" <<++ 1>>readme.log 2>&1
user "username" "password"
prompt off
lcd /backup/data
mget *
find /backup/data/ -name '*'\.\txt -type f -print|while read FILENAME
ls -altr "${FILENAME}" >> /backup/data/files.log
iconv -f windows-1256 -t UTF-8 "${FILENAME}" > "${FILENAME%.txt}_utf8.txt"

But my connection is hanging for endless feeds from user, leave everything else coming after it.

Kindly advise.

Roshan Nair
Old 02-16-2009, 01:29 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

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 ;-)):

2. Here are two simple examples of working FTP scripts:

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...

'Hope that helps .. PSM
Old 02-16-2009, 02:00 AM   #3
LQ Newbie
Registered: Feb 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Hi Paul,

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 "", which would pull commands from ftp_commands.lst. A similar thing in windows worked for me, but not here I guess.

[oracle@shamilrep scripts]$ cat
ftp -i < /oracle/scripts/ftp_commands.lst
[oracle@shamilrep scripts]$ cat ftp_commands.lst <<!
user username password
cd /data/checkup
lcd /backup/Oracle-Backup/EIM_data_extract
mget *




connection, ftp

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Enumerating Files In The Linux or Unix Shell - More Improvements LXer Syndicated Linux News 0 06-05-2008 10:30 AM
FTP Tree - Uploading Files using DREAMWEAVER luyznascimento Red Hat 3 01-07-2007 12:06 PM
ftp problem with uploading big files joeSVK Linux - Networking 2 05-10-2005 04:52 AM
ftp - trouble uploading files icehenge Linux - Newbie 4 04-29-2004 04:54 PM
Connection, login and upload files to ftp server via shell script Paulo Ges Linux - Networking 2 02-21-2004 02:01 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration