- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Problem with FTP script
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-16-2004 03:45 AM
02-16-2004 03:45 AM
Problem with FTP script
Here's the script.
for SERVER in `cat /tmp/servers`
do
echo "FTP to $SERVER"
sleep 1
ftp -in <<-EOF
open $SERVER
user
ascii
lcd /tmp
cd /tmp
put file1
put file2
chmod 700 /tmp/file2
bye
EOF
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 03:52 AM
02-16-2004 03:52 AM
Re: Problem with FTP script
Perhaps there is a non-visual junk character in the username or password?
The script looks good.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 03:52 AM
02-16-2004 03:52 AM
Re: Problem with FTP script
for SERVER in `cat /tmp/servers`
do
echo "FTP to $SERVER"
sleep 1
ftp -in <<-EOF
open $SERVER
user
ascii
lcd /tmp
cd /tmp
put file1
put file2
chmod 700 /tmp/file2
bye
EOF
done
based on the fact that if a user needs a password, the ftp server will prompt for it with something like
user blah needs a password:
Enjoy, Have FUN! H.Merijn [ who would use perl -MNet::FTP ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 04:02 AM
02-16-2004 04:02 AM
Re: Problem with FTP script
breaking the user line to
user
causes the script to pause and ask for my password. I can type in the same password in the script and it continues fine and sends the files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 04:04 AM
02-16-2004 04:04 AM
Re: Problem with FTP script
I would try couple of checks.
1. Try with hardcoding the servername in side the ftp script. Take out the for loop.
2. Run it with -v and look at the session log. See if the password is really being passed.
I copied and pasted your script without the for loop and it is working just fine for me.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 04:08 AM
02-16-2004 04:08 AM
Re: Problem with FTP script
Here is the result:
root@cosmo0:/tmp-> ./ftp1
Connected to
220-####################################################
220-# #
220-# This is a restricted server. Only authorized #
220-# users may access this server. All activity is #
220-# monitored and any unauthorized use will be #
220-# reported to the appropriate authorities. #
220-# #
220-####################################################
220-
220-
220 FTP server ready.
Remote system type is UNIX.
Using binary mode to transfer files.
331 Password required for
530 Login incorrect.
Login failed.
200 Type set to A.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
221 Goodbye.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 04:28 AM
02-16-2004 04:28 AM
Re: Problem with FTP script
Looks like it didn't like the password. Try with a simple password to test your ftp script.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 04:38 AM
02-16-2004 04:38 AM
Re: Problem with FTP script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 04:44 AM
02-16-2004 04:44 AM
Re: Problem with FTP script
file=test.txt
ftplogfile=/tmp/ftplogfile.log
ipaddress=yourhostname
ftp -nv <
open $ipaddress
user username password
ascii
cd /remote_directory
put $file remotefilename
site chmod 770 remotefilename
bye
EOF
You'll need to substitute yourhostname, username, password, remote_directory, remotefilename
Works every time. One thng to watch out for is sometimes indenting the lines between EOF's can upset ftp. I always left justify the block even inside a loop.
Regards,
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 05:04 AM
02-16-2004 05:04 AM
Re: Problem with FTP script
Run the FTP command with the -i option to disable interactive prompting. Your script with the ID and password on the same line should then work ok.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 10:07 AM
02-16-2004 10:07 AM
Re: Problem with FTP script
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 10:27 AM
02-16-2004 10:27 AM
Re: Problem with FTP script
Also attached for formatted codeis not supported yet
#!/opt/perl/bin/perl
use strict;
use warnings;
use Net::FTP;
@ARGV = ("/tmp/servers");
while (<>) {
chomp;
my $ftp = Net::FTP->new ($_, Debug => 3) or
die "$_: cannot connect: ", $ftp->message;
$ftp->login ('user', 'password') or
die "$_: cannot logon: ", $ftp->message;
$ftp->ascii or
die "$_: cannot set ascii mode: ", $ftp->message;
chdir "/tmp" or die "/tmp: $!\n";
$ftp->cwd ("/tmp" or
die "$_: cannot chdir to /tmp: ", $ftp->message;
foreach my $file (qw( file1 file2 )) {
$ftp->put ($file) or
die "$_: cannot put $file: ", $ftp->message;
# I have no idea how to do chmod in Net::FTP
# chmod 700 /tmp/file2
$ftp->quit;
}
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 08:34 PM
02-16-2004 08:34 PM
Re: Problem with FTP script
#!/opt/perl/bin/perl
use strict;
use warnings;
use Net::FTP;
@ARGV = ("/tmp/servers");
while (<>) {
chomp;
my $ftp = Net::FTP->new ($_, Debug => 3);
$ftp or die "$_: cannot connect: $@";
$ftp->login ('user', 'password') or
die "$_: cannot logon: " . $ftp->message;
$ftp->ascii or
die "$_: cannot set ascii mode: " . $ftp->message;
chdir "/tmp" or die "/tmp: $!\n";
$ftp->cwd ("/tmp") or
die "$_: cannot chdir to /tmp: " . $ftp->message;
foreach my $file (qw( file1 file2 )) {
$ftp->put ($file) or
die "$_: cannot put $file: " . $ftp->message;
# I have no idea how to do chmod in Net::FTP
# chmod 700 /tmp/file2
$ftp->quit;
}
Should be better.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2004 12:26 AM
02-17-2004 12:26 AM