Auto FTP to a server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Auto FTP to a server
# 1  
Old 03-17-2006
Auto FTP to a server

Hi,

I am trying to automate FTP login to a remote server and put a file there. But no matter what i do, It still is aksing me for the login and password although i have it defined in the variable.

Quote:
SERVER=123.456.789
USER=root
PASSWD=password


if [ $# -eq 0 ]
then
echo "Usage ./ftp.sh <file name>"
exit 0
fi

ftp $SERVER
user $USER $PASSWD
cd /usr/local/home/abc
binary
put testfile

wait
exit 0
Could you tell me what is wrong with this script. I am doing this on SUN server.

Pls assist.

Thanks
# 2  
Old 03-17-2006
All those ftp commands should be within a here-document. Or use the co-process technique.

You should find them in the FAQ section.
# 3  
Old 03-17-2006
Thank you so much VINO as always, you have been very helpful Smilie

3 cheers to you !
# 4  
Old 03-17-2006
One more thing vino,

If i need to read the codes for FTP how can i do that ..for example

Quote:
220 svpkg1-nd FTP server () ready.
331 Password required for admin1.
230 User admin1 logged in.
250 CWD command successful.
200 PORT command successful.
550 tatu: No such file or directory.
221 Goodbye.
I need to validate on code 550 and echo a message that the specified file was not found.

How can we do this.

Thanks once again Smilie
# 5  
Old 03-17-2006
Search the forum with the keywords "ftp result code". You will find a couple of posts which will help you out.
# 6  
Old 03-21-2006
I have ready script

I have automated that FTP script few days back and i think ur requirements are almost same...if ur prob is not yet solved will give u that script
# 7  
Old 03-21-2006
Hi Dhruv,

Please do share it here, Will be handy for every one.

Any ways, here is how i did it :-

Quote:
#!/bin/sh

# Variables that will be used.

SERVER=12.456.789
USER=username
PASSWD=password
PATH=/your/path/here

#Check if a valid input has been given

if [ $# -eq 0 ]
then
echo "Usage ./getftp.sh <file name to get>"
exit 0
fi

#Connecting via FTP to fetch a desired file.

/usr/bin/ftp -v -n "$SERVER" << cmd
user "$USER" "$PASSWD"
cd $PATH
binary
get $1
quit
cmd
echo "\n FTP session closed "

#Make Sure if the file has reached destination.

if [ -f $1 ]
then
echo "\n Hueston we have received the package\n"
else
echo "\n Oh oo..$1 does not exist on source"
fi

#Start your Validation.

exit 0
Hope this helps some one Smilie

Cheers !!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Implement FTP server on RHEL server without using FTP client

We have RHEL 5.8 in our environment, I had a query whether we can implement an FTP server using vsftpd package and Linux configurations like setsebool without using any external FTP clients like FileZilla etc. I am very confused on this. The FTP functionalities that should be present are download &... (3 Replies)
Discussion started by: RHCE
3 Replies

2. Shell Programming and Scripting

[Need HELP] Find aging file and auto FTP

Dear Experts, I have script to find aging file like this: find /ArchiveINTF/INTF name "*" -type f -mtime +365 {} \; >> agingfile.txt This script will find all files over 365 days. But, I have problem, how to auto FTP all files? Thanks Edy (3 Replies)
Discussion started by: edydsuranta
3 Replies

3. Homework & Coursework Questions

How to auto telnet the server from another server?

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' 1. The problem statement, all variables... (8 Replies)
Discussion started by: atul9806
8 Replies

4. Homework & Coursework Questions

How to auto telnet the server from another server

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' 1. The problem statement, all variables... (0 Replies)
Discussion started by: atul9806
0 Replies

5. Shell Programming and Scripting

How to auto telnet the server from another server using script

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' I have to write a script, which is ran... (0 Replies)
Discussion started by: atul9806
0 Replies

6. Shell Programming and Scripting

Auto Ftp pseudo random file

I have a script that generates a file which is my own incarnation of a date using the 'date' function (we'll call this script a). I would like that script to invoke my other script (script b) which contains my ftp info. Since I have yet to figure out a good way to use regular ftp (yes i can only... (6 Replies)
Discussion started by: DC Slick
6 Replies

7. Solaris

Sun Server auto ping to 0.0.0.0

Hi All, 3 of my SAP sun server are continuosly pinging to the network address 0.0.0.0. I have no idea how this can happen, but they have something in common. All of them are clustered environment (Veritas Cluster). Anyone can help? rgds, (5 Replies)
Discussion started by: ronny_nch
5 Replies

8. UNIX for Advanced & Expert Users

Count and Auto FTP

Hi, I really need to create a script that counts for file and ftp's them to a windows directory. !st problem i'm having is getting it to ftp withouty prompting me, i tried |& on the end of the ftp, but then it just hits a syntax error. 2nd problem is, i have to have a wildcard in this script. which... (3 Replies)
Discussion started by: dappa
3 Replies

9. Shell Programming and Scripting

auto ftp the files

i have writen a shell to ftp a file automatically by taking the input from a file i have created on file tstftp as set timeout 120 ftp spawn ftp expect "ftp>" send "o 11.90.2.20 \r" expect "Name:" send "itcomxxl\r" expect "Password:" send "csms091206\r" expect "ftp>" send "prompt... (1 Reply)
Discussion started by: sasiprabu
1 Replies

10. Programming

Auto FTP from UNIX to Windows Server

Hi, I am a not strong programmer and now my boss ask me how should I do a job to automated FTP that have error check. I know about: * using system() to call a command to trigger ftp in C Coding. The senarios as follows: 1. FTP the file(s) (e.g ELA_20060407.dat) to a given LAN server... (1 Reply)
Discussion started by: songtam
1 Replies
Login or Register to Ask a Question