Script to ftp in non-ineractive mode


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to ftp in non-ineractive mode
# 1  
Old 09-18-2007
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  
Old 09-18-2007
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  
Old 09-18-2007
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  
Old 09-18-2007
Quote:
Originally Posted by mshv123
Unfortunately there is no such file in my home directory.
Are you not able to create one?
# 5  
Old 09-18-2007
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  
Old 09-18-2007
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
# 7  
Old 09-18-2007
It's interesting. I'll try it tomorrow and let you know about results.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP to send files using Binary mode

I am using below code to send files into ascii mode.what changes will I have to do to send files into Binary mode ? ftp -in <<FIN open $SAP_UP_SERVER user $SAP_UP_USER $SAP_UP_PASSWORD asc put $PM00_OUTPUTS_DIRECTORY/$SAP_UP_FILE_CSV /SAP_UP_FILE_CSV quit FIN (1 Reply)
Discussion started by: Nitin Varshneya
1 Replies

2. Shell Programming and Scripting

FTP in batch mode

HI, Need to ftp a bunch of files in a directory in batch mode. TRying to ftp a single file first with below code. #!/bin/ksh function ftp_files { ftp -n ${D2_SRVR} <<-EOF quote user ${D2_UID} quote pass ${D2_PWD} cd ${D2_DIR}/${D2_NAME} lcd ${D1_DIR}/${D1_NAME}/dml/ put file1 ... (6 Replies)
Discussion started by: cvsanthosh
6 Replies

3. Linux

active mode ftp connection from linux

Hi, We have one java client which connects to a windows server through ftp in active mode and gets files. When we run this client on hp-ux, it is able to transfer 100k files. But when we run the same client on Linux server it is able to transfer only 200 files at max and it is hanging there... (1 Reply)
Discussion started by: urspradeep330
1 Replies

4. AIX

ftp connect in passive mode , ftp settings

how to connect to ftp server in passive mode? ftp server.abc and how can i see ftp settings, doesn't exist some ftpd.conf there is some other file where i check the options and configurations of ftp server? Thanks (3 Replies)
Discussion started by: prpkrk
3 Replies

5. Shell Programming and Scripting

change the mode of the file after FTP

Hi I am FTPing a file to a remote server from my local server. But after I FTP it the permissions are not in executable option, I need to change the permissions of the FTPed file how can i do that. Below is my script LOCALDIR=/batch/ediprocess LOCAL_BACKUP_DIR/batch/ediprocessBackUp... (4 Replies)
Discussion started by: shanth_chandra
4 Replies

6. Shell Programming and Scripting

Automate ineractive applications

Hi Friends, I have a ksh script which is created by a user, 'ustst'. I need to su to another user, 'ghprod' and execute a script created by 'ghprod'. su - ghprod The above cmd asks for ghprod's password. I need to automate such that it takes the password form a hidden file without prompting... (1 Reply)
Discussion started by: sudvishw
1 Replies

7. Solaris

FTP is in maintenance mode always

Hello All, On solaris 10 server i could see the FTP service is in maintenance mode always :mad: Could some assist? svcs -xv svc:/network/nfs/nlockmgr:default (NFS lock manager) State: maintenance since Tue 28 Jul 2009 11:47:55 AM BST Reason: Restarting too quickly. See: Sun... (5 Replies)
Discussion started by: bullz26
5 Replies

8. Shell Programming and Scripting

How to check a file whether it is in binay mode or not while doing ftp??

Hi, One bank statement file should be loaded into some tables by using a concurrent program. But if the file is transfered in binary mode i am getting some special characters in the file which is unexpected. so, for that while moving that file data into tables i want to write a script that... (2 Replies)
Discussion started by: sateesh.d
2 Replies

9. IP Networking

Transfering file through FTP through Binary Mode

Hi, I'm uploading files using internet explorer. 1.Open internet explorer 6.0 2.Open site like ftp://172.45.15.1 3.Copy files The files which I'm copying are basically zip files. What is the default transfer mode, I mean ASCII/BINARY ???. The problem I'm facing, while extracting these... (4 Replies)
Discussion started by: ronald_brayan
4 Replies

10. UNIX for Advanced & Expert Users

PASV mode FTP

Hello, We have a situation wherein the FTP connections from a Client over a secure connection like ANX, when using PASV mode file transfers, the server on our end is sending out an ip address as (0,0,0,0,0,0) for PASV mode. The first four numbers denote the ip address and the last two denote the... (5 Replies)
Discussion started by: jerardfjay
5 Replies
Login or Register to Ask a Question