The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 05:26 PM
How to run shell script in silent mode x057373 UNIX for Dummies Questions & Answers 3 12-04-2005 08:26 PM
PASV mode FTP jerardfjay UNIX for Advanced & Expert Users 5 10-13-2005 03:17 PM
PAM Vs Trusted mode in HP-UX wilsonchan1000 UNIX for Dummies Questions & Answers 0 07-26-2004 06:58 AM
Interactive Mode? Nomad UNIX for Dummies Questions & Answers 2 08-16-2002 06:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-18-2007
mshv123 mshv123 is offline
Registered User
  
 

Join Date: Sep 2007
Location: NYC
Posts: 4
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
  #2 (permalink)  
Old 09-18-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
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.
  #3 (permalink)  
Old 09-18-2007
mshv123 mshv123 is offline
Registered User
  
 

Join Date: Sep 2007
Location: NYC
Posts: 4
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"
  #4 (permalink)  
Old 09-18-2007
porter porter is offline Forum Advisor  
Registered User
  
 

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

Join Date: Sep 2007
Location: NYC
Posts: 4
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
  #6 (permalink)  
Old 09-18-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 707
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
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0