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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-16-2009, 12:17 AM
|
#1
|
|
LQ Newbie
Registered: Feb 2009
Posts: 5
Rep:
|
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
|
|
|
|
02-16-2009, 12:29 AM
|
#2
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
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
|
|
|
|
02-16-2009, 01:00 AM
|
#3
|
|
LQ Newbie
Registered: Feb 2009
Posts: 5
Original Poster
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:20 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|