- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- FTP script commands
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
Discussions
Discussions
Forums
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
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
тАО09-26-2002 04:25 AM
тАО09-26-2002 04:25 AM
I've used to be a VB-programmer but I recently switched jobs and now I'm a oracle developer.
I need to build a UNIX ftp script that gets or puts a certain file from/to a certain directory. I've got some sample scripts and I think I can copy/paste enough to get what I need. Problem is that I don't like code in my scripts that I don't fully understand.
Can anybody give me some tips/ links to sites where I can get good information about the mentioned subject?
script so far:
################
## Constants ##
################
FILE=$1
SERVER=$2
USERNAME=$3
PASSWORD=$4
FTP_DIR=$5
#LOCAL=$6
#######################
# Validate Parameters #
#######################
if [ ! "$FILE" ]
then
echo "Must Pass a FILE"
exit 1
fi
if [ ! "$SERVER" ]
then
echo "Must Pass a SERVER name"
exit 1
fi
if [ ! "$FTP_DIR" ]
then
echo "Must Pass a FTP Directory"
exit 1
fi
if [ ! "$LOCAL" ]
then
echo "Must Pass a LOCAL Directory"
exit 1
fi
########################
# LOG #
########################
LOG=/tmp/$1.log
IP_ADDRESS=$2
USERNAME=$3
PASSWORD=$4
########################
#Start Ftp and get file#
########################
ftp -nv ${SERVER} << FTPEOF > /tmp/temp_log.$$
user ${USERNAME} ${PASSWORD}
#Get file
get $1
quit
-------------------
I found (somewhere on the net) what ftp -nv means but what's going on with the <
Regards,
sander
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2002 04:33 AM
тАО09-26-2002 04:33 AM
Re: FTP script commands
have a look at this thread, as I prefer Clay's method:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x459a8cc5e03fd6118fff0090279cd0f9,00.html
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2002 04:53 AM
тАО09-26-2002 04:53 AM
Re: FTP script commands
The other construct, "> /tmp/temp_log.$$", sends the ftp output into a file named "/tmp/temp_log.$$".
Sounds like you need a good book/tutorial on shell programming. There are a number of shells: sh, csh, ksh, bash, ... I favor ksh, but you should ask your colleagues what they use - then you can always ask them for help, and they will be able to understand your scripts.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2002 05:27 AM
тАО09-26-2002 05:27 AM
Solution########################
#Start Ftp and get file#
########################
ftp -nv ${SERVER} << FTPEOF > /tmp/temp_log.$$
user ${USERNAME} ${PASSWORD}
#Get file
get $1
quit
FTPEOF
The "FTPEOF" which signifies the end of the here doc commands was missing. Perhaps it's there but just wasn't in you post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2002 10:48 PM
тАО09-26-2002 10:48 PM
Re: FTP script commands
thnx for the replies!
Tom you are correct I need a good book. But since programming these (simpel) scripts happens about 1 a year for us I was hoping that there where some good sites in wich this script programming is explained.
Regards,
Sander
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2002 04:05 AM
тАО09-27-2002 04:05 AM
Re: FTP script commands
Anyone can do a ps -ef while it's running and see your password.
Either put it in the file like Sandip and Clay did in the link that was given,
or ask for it when the command is executed.
Ex:
echo "Enter Password: \c"
read password
ftp -nv
open ftp.mysite.com
user $user
pass $password
......
..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2002 08:18 AM
тАО10-02-2002 08:18 AM
Re: FTP script commands
The construct you refer to is commonly called a 'here doc'. What it means is that the text following the << is redirected to stdin, as if you typed it on the keyboard. The FTPEOF is the end marker. Actually, there is an error in your code. It should read as follows:
ftp -nv ${SERVER} << FTPEOF > /tmp/temp_log.$$
user ${USERNAME} ${PASSWORD}
#Get file
get $1
quit
FTPEOF
Note the FTPEOF at the end of the file. This tells the redirection to stop at that point.
Hope this helps,
Mark