LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 02-16-2009, 12:17 AM   #1
alertroshannow
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 "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.

Kindly advise.

Roshan Nair
 
Old 02-16-2009, 12:29 AM   #2
paulsm4
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 ;-)):
http://tldp.org/LDP/abs/html/here-docs.html

2. Here are two simple examples of working FTP scripts:
http://www.computing.net/answers/uni...hpux/7009.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...

'Hope that helps .. PSM
 
Old 02-16-2009, 01:00 AM   #3
alertroshannow
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 "conn.sh", 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 conn.sh
ftp -i < /oracle/scripts/ftp_commands.lst
[oracle@shamilrep scripts]$ cat ftp_commands.lst
11.11.11.11 <<!
user username password
cd /data/checkup
binary
prompt
lcd /backup/Oracle-Backup/EIM_data_extract
mget *
bye

***************************************************

-Rgds,
Roshan
 
  


Reply

Tags
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 09:30 AM
FTP Tree - Uploading Files using DREAMWEAVER luyznascimento Red Hat 3 01-07-2007 11:06 AM
ftp problem with uploading big files joeSVK Linux - Networking 2 05-10-2005 03:52 AM
ftp - trouble uploading files icehenge Linux - Newbie 4 04-29-2004 03:54 PM
Connection, login and upload files to ftp server via shell script Paulo Ges Linux - Networking 2 02-21-2004 01:01 PM


All times are GMT -5. The time now is 09:51 AM.

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