The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
split bus mode Arkayev SUN Solaris 18 07-31-2007 02:26 PM
How to run shell script in silent mode x057373 UNIX for Dummies Questions & Answers 3 12-04-2005 04:26 PM
PASV mode FTP jerardfjay UNIX for Advanced & Expert Users 5 10-13-2005 12:17 PM
PAM Vs Trusted mode in HP-UX wilsonchan1000 UNIX for Dummies Questions & Answers 0 07-26-2004 03:58 AM
Interactive Mode? Nomad UNIX for Dummies Questions & Answers 2 08-16-2002 03:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-18-2007
Registered User
 

Join Date: Sep 2007
Location: NYC
Posts: 4
Stumble this Post!
Script to ftp in non-ineractive mode

Hi,

I am relatively new to Unix. What I am trying to create now is a script to ftp some file(s) from Unix server to Windows ( not mine) machine. It should be able to run not in interactive mode, eventually I will schedule it to run at certain time intervals.

So far I have created the following script:

ftp windows_server_name
USER my_account_on_win_server
PASS my_password there
put dir_name/file_name
bye


However when I run it it behaves interactively, it asks me for user name and password on target machine anyway. My question is what should I change in this script to make it non-interactive ? My shell is ksh.

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-18-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
Use a file in your home directory called ".netrc", put all user names/passwords in this file and ftp will look it up rather than ask you.
Reply With Quote
  #3 (permalink)  
Old 09-18-2007
Registered User
 

Join Date: Sep 2007
Location: NYC
Posts: 4
Stumble this Post!
Unfortunately there is no such file in my home directory.
I tried "more .netrc" in both /home/ and /home/myaccount/ but in either case it gave a message ".netrc: No such file or directory"
Reply With Quote
  #4 (permalink)  
Old 09-18-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
Quote:
Originally Posted by mshv123 View Post
Unfortunately there is no such file in my home directory.
Are you not able to create one?
Reply With Quote
  #5 (permalink)  
Old 09-18-2007
Registered User
 

Join Date: Sep 2007
Location: NYC
Posts: 4
Stumble this Post!
Yes I can create it. It looks like this:

user my_win_login
pass my_win_password

The script now looks like this:

ftp win_server
put file_name
bye

I run it as:

sh my_script

but it still asks for login name and password
Reply With Quote
  #6 (permalink)  
Old 09-18-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 505
Stumble this Post!
Hi.

It worked for me -- Debian Linux to SuSE Linux.

There were two requirements:

1) a line with "machine name"

2) read permissions only for owner

After meeting those, the operation seemed to work. Here is a little script that creates a file and transfers it. I turned on verbose mode to display the operations:
Code:
#!/bin/sh -

# @(#) s1       Demonstrate auto-login for ftp.

( date; echo " Hello, world." ) > t1

ftp -v limb <<'EOF'
put t1
quit
EOF

exit 0
Producing:
Code:
% ./s1
Connected to limb.
220 limb.local FTP server (Version 6.5/OpenBSD, linux port 0.3.3) ready.
331 Password required for drl.
230- Have a lot of fun...
230 User drl logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
local: t1 remote: t1
200 PORT command successful.
150 Opening BINARY mode data connection for 't1'.
226 Transfer complete.
44 bytes sent in 0.00 secs (1074.2 kB/s)
221 Goodbye.
The .netrc file looks like:
Code:
% cat ~/.netrc
machine limb
login drl
password (secret)
Best wishes ... cheers, drl
Reply With Quote
  #7 (permalink)  
Old 09-18-2007
Registered User
 

Join Date: Sep 2007
Location: NYC
Posts: 4
Stumble this Post!
It's interesting. I'll try it tomorrow and let you know about results.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0