Connecting Tech Pros Worldwide Forums | Help | Site Map

ftp from unix to windows - urgent help required

Newbie
 
Join Date: Sep 2007
Posts: 1
#1: Sep 4 '07
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

Member
 
Join Date: Jan 2007
Posts: 69
#2: Sep 5 '07

re: ftp from unix to windows - urgent help required


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

Quote:

Originally Posted by samsalmanu

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

docdiesel's Avatar
Moderator
 
Join Date: Aug 2007
Location: Munich
Posts: 289
#3: Sep 7 '07

re: ftp from unix to windows - urgent help required


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
Reply


Similar Unix / Linux / BSD bytes