By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,212 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,212 IT Pros & Developers. It's quick & easy.

ftp from unix to windows - urgent help required

P: 1
I'm trying to ftp from a Unix machine to a Windows machine..

I've tried the following

#!/bin/sh
#set -x
USER="user1"
PASS="pass1"
HOSTNAME="host1"

ftp -n -i -v $HOSTNAME << EOT
user $USER $PASS
cd /
send text1.txt
close
bye
EOT

When I try to run this, I get prompted for the password. But since this will be working in a Production environment and run by people who have no idea what this script will be doing , the process should be automated. The user id and password have to go in automatically and the file should be put in.

I've tired different options like
ftp -n -i -v << EOT
open $HOSTNAME
$USER
$PASS
cd /
send text1.txt
close

as well as
ftp -n << EOT
open $HOSTNAME
quote USER $USER
quote PASS $PASS
cd /
send text1.txt
close

but always I keep getting the same error, where I'm prompted for the password.

Output when running script
----------------------------------
****
Connected to host1
220 FTP server (Hummingbird Ltd. (HCLFTPD) Version 9.0.0.0) ready.
331 Password required for user1
***

This is kind of urgent. Any help would be greatly appreciated.

Thanks
Sam
Sep 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: 69
I've used in csh script the following (ftp session should be the same):

Expand|Select|Wrap|Line Numbers
  1.  
  2.       ftp  -i -n -v <<End
  3.       open <ipaddress>
  4.       user <usr_name> <pwd>
  5.       lcd $SOURCE_DIR
  6.       cd $DEST_DIR
  7.       binary
  8.       put $FNAME
  9.       close
  10.       bye
  11. End
  12.  
It works on Solaris!

diSangro

I'm trying to ftp from a Unix machine to a Windows machine..

I've tried the following

#!/bin/sh
#set -x
USER="user1"
PASS="pass1"
HOSTNAME="host1"

ftp -n -i -v $HOSTNAME << EOT
user $USER $PASS
cd /
send text1.txt
close
bye
EOT

When I try to run this, I get prompted for the password. But since this will be working in a Production environment and run by people who have no idea what this script will be doing , the process should be automated. The user id and password have to go in automatically and the file should be put in.

I've tired different options like
ftp -n -i -v << EOT
open $HOSTNAME
$USER
$PASS
cd /
send text1.txt
close

as well as
ftp -n << EOT
open $HOSTNAME
quote USER $USER
quote PASS $PASS
cd /
send text1.txt
close

but always I keep getting the same error, where I'm prompted for the password.

Output when running script
----------------------------------
****
Connected to host1
220 FTP server (Hummingbird Ltd. (HCLFTPD) Version 9.0.0.0) ready.
331 Password required for user1
***

This is kind of urgent. Any help would be greatly appreciated.

Thanks
Sam
Sep 5 '07 #2

docdiesel
Expert 100+
P: 297
Hi,

I tried this, too, some time ago, and ended up with the very same problem. As far as I learned from this tests, ftp on the Linux installations I know doesn't like passwords from files, pipes or other streams. As soon as it detects that there's a TTY/console to interact with you, it will ask for a pwd. But I didn't try calling it via cron.

Btw., ever thought of transfering files/data automatically with ssh or rsync?

Regards, Bernd
Sep 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.