- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to ftp file from HP-UX server to a wind...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 07:54 AM
02-18-2004 07:54 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 08:13 AM
02-18-2004 08:13 AM
SolutionThe attached script, ftpput.pl, would login to a remote server and put the files listed on the command line.
ftpput.pl myfile1 myfile2
would put both of these files and return a 0 exit code upon success.
Note in the code where the login is done. Yopu could simply supply the user and the password could be read from the .netrc file. That section of code is commented. Man .netrc, Net::FTP for details. I think that you will find that this method is much cleaner than shell scripting for FTP operations especially if you deal with those pesky little trivial issues like checking for errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 11:45 AM
02-18-2004 11:45 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
# more putdbfile.sh
#!/usr/bin/sh
ftp -n IP_OF_Windows2003 <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 01:55 AM
02-19-2004 01:55 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
ftp -n ip_address_of_server ,,!
user USERNAME PASSWORD
binary
cd $rdmpdir (generated in the unix script, it is the dir on the windows server)
put $dmpfil (generated in unix script, changes daily)
bye
!
Can I cd to the required directory? If not what command do I need to use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 02:13 AM
02-19-2004 02:13 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
I appreciate your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 02:43 AM
02-19-2004 02:43 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
Run your script so:-
ksh -x <scriptname>
It will show yoy where it is failing.
I would also echo back the $rdmpdir to confirm thjat it is correct, maybe it requires the full windoze path c:\bla\bla\dir.
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 02:53 AM
02-19-2004 02:53 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
unix script generates the file and directory but i do not know how to pass to windows.
previous part of script that generates the DAY portion of file not shown. this script currently runs oK going from hp server to hp server but I'm getting errors on the $dmpfil on the windows server. I tried using double quotes around the "$dmpfil" in the put command. See below:
dmpfil="RP5470full_${Day}.dmp.Z"
ldmpdir="/u08/oracle/bob/exp/"
cd $ldmpdir
ftp -n IP_ADDRESS_OF_SERVER << ENDFTP
user USER PASSWORD
cd "E:\oracle\oradata\alice\RP5470_SAVE"
put $dmpfil
bye
ENDFTP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 03:20 AM
02-19-2004 03:20 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
Another item is that you are using the shorthand version of put. put normally requires 2 parameters, source and destination. If you leave out the destination then the source is repeated for the destination. In your case, just the filename is sent so as long as the filename is valid (never assume that special characters are valid for filenames) then the file should be created. But of course, the Windows system may have permission issues, etc.
Also, never assume you have the right mode (ASCII or BINARY). Always explicitly code the translation method in your script. Since this is a .Z file, you'll need BINARY to prevent corruption of the file at the Windows side.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 03:57 AM
02-19-2004 03:57 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
How can I specify or change the filename?
put $dmpfile variablefilename.zip
Thanks to all of you for taking the time to help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 04:26 AM
02-19-2004 04:26 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
Something like this:
USER=user
PASSWORD=password
CMDFIL=/tmp/ftp.cmd
FILENAME=myfile
TGTFILENAME=newfile.zip
echo "open server" > ${CMDFIL}
echo "user ${USER} ${PASSWORD}" >> {$CMDFIL}
echo "cd ${DIRECTORY}" >> ${CMDFIL}
echo "put ${FILENAME} {$TGTFILENAME}" >> ${CMDFIL
eval "ftp -n < ${CMDFIL}"
This way all the complicated logic about filenames, etc, can be done in the script .. the ftp command file only has literal values in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 04:56 AM
02-19-2004 04:56 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
My last attempt included the following:
In the unix script, I determined the file and then uncompressed the file on the unix server. Setting the variable again for just the uncompressed file name. Then the ftp portion of the script executed. It ran, but the total kb is different on the windows server than what is displayed on unix. I will look into your suggestion. I'm going to make a couple more tests but it looks like it is working. Like I said, I've just got to verify the ftp'd file size is correct. Anyway, I really appreciate yours and everyone's help. In researching, looks like the windows command to compress is compact? I'll give that a try. I want to automate all this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 05:43 AM
02-19-2004 05:43 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
If you are dealing with text files, then you may need to do a "ux2dos" on the UNIX file first. If you are dealing with compressed files, like .Z or .gz files, then you may not need to uncompress them before sending them to Windows .. many of the Windows zip utilities will also read .Z and .gz files with no problem.
Don't forget to hand out points to all those people you are wishing to express your gratitude for. :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 10:02 AM
02-19-2004 10:02 AM
Re: script to ftp file from HP-UX server to a windows 2003 server
1) In your home directory (or the sender's home directory) create a file called .netrc with 600 (rw-------) permissions owned by the sender.
Have an entry like this:
machine remotehost login cstephen password topsecret account mostsecret
The account data is required on boxes which add an extra layer of authentication. You probably won't need that. Man .netrc for details.
2) cd to the desired directory on the local host
3) ftpput.pl -h remotehost -B -d dirname -t 4 -v file1 file2 file3
STAT=${?}
That will ftp to remotehost, attempt to login as the current user using password and account data in .netrc. -B specifies binary xfers, -d dirname cd's to dirname on the remote host, -t 4 tells it to try to send a file up to 4 times before giving up. -v set verbose. Finally, file1 file2, file3 are sent. You don't have to check file sizes or do checksums, if ${?} is zero then everything (login,hostname,xfers) was okey-dokey.
Invoke this puppy as ftpput.pl -u for full usage.