4 replies
by stillatit
Take your script to the point where you have the current name of the the file and the new name you want the file to be. Shove those names in two variables:
MYCURRENTNAME=currentname
MYNEWNAME=giveitthisname
(whatever they are). Now write a tempory file in a secure directory to which only you have read access:
MYTEMPFILE='/home/username/mysecure/mytemp'
# variable for the secure location and file name
HPADDR="1.2.3.4"
# variable for the IP address of the HP box - put in the right address
#
MYUSER="username"
# replace 'usernamne' with your user name on the HP
MYPASS="mypassword"
# replace 'mypassword' with your password on the HP
#
#
echo "open $HPADDR" > $MYTEMPFILE
# connect to the HP
echo "user $MYUSER $MYPASS" >>$MYTEMPFILE
# log in
echo "bin" >> $MYTEMPFILE
# force binary
#
echo "put $MYCURRENTNAME $MYNEWNAME" >> $MYTEMPFILE
# having the two names causes a rename in transit.
echo "bye" >> $MYTEMPFILE
# now execute ftp and execute the commands.
# The -n inhibits automatic login.
/usr/bin/ftp -n <$MYTEMPFILE
# and kill off the temp file
/usr/bin/rm $MYTEMPFILE
#At this point you may want to move the file to a "sent" folder in case the HP loses it.
NEWLOC="../sent"
# Put in the path where you want the sent files to go
/bin/mv $MYCURRENTNAME $NEWLOC/$MYNEWNAME
# or kill it, or whatever
Alternately you could have the first three lines (open, user, bin) in a file in your secure directory, and copy that into the new temp file name, then append the rest of the lines. That puts the password only in your unreadable directory rather than in a script.
Good luck.
by it1
by it1
by it1
This discussion is closed to new replies.
Trending Linux posts
Sort by Trending