Ftping through unix script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Ftping through unix script
# 8  
Old 12-01-2006
Thanks!! Its ok but i am able to transfer files on remote host through scripting the problem i have is in counting number of files ftped there on remote host.

please see the 4th post from Shiv_jad to this thread.
waiting for favorable solution.
shiv Smilie
# 9  
Old 12-01-2006
Redirect your ftp output to a ftp_log file and parse the file to get the file count from there

Code:
ftp -nv $HOST <<EOF1 >>some_ftp_log.log

# 10  
Old 12-01-2006
Thanks for your quick reply madhan, but its giving me error as file can not be created. my script is as follows.


ftp -v -n $HOST_NAME <<cmd >>LOGFILE
user $HOST_USERNAME $HOST_PASS
cd /data_ca/ftpdir
mput *
nlist
#get count of files ftped to this location
quit
cmd

Also tell me where this LOGFILE should be created? the path from where i am running the script on local host?? Also i want the count of files ftped to the remote host. so suggest the code to be included below the commentline in above code.

Thanks
Shiv@jad
# 11  
Old 12-01-2006
You can create the file anywhere which is comfortable to you Smilie.
If you are not able to create the log file, check for the permissions and work out appropriately.
In the log file, there would be file transfer message, you need to grep that count and you would have the files transferred.
# 12  
Old 12-01-2006
FTP script and log file

Matrix is right on. If you can't create a log file permissions is most likely the issue. Here is a script I created doing what you want. The count issue you will get by sorting through the log file created.

#!/bin/sh
#set -v
echo NOTE: check ftplog for connection info
rm ftplog
date >>ftplog

HOST='192.168.0.214 5021'
USER='user01'
PASSWD='user01'
FILE='/home/dude/file.txt'

ftp -v -n $HOST >>ftplog 2>&1 <<EOJ
quote USER $USER
quote PASS $PASSWD
debug
pwd
passive
pwd
put $FILE
ls
close
bye
EOJ
exit 0
# 13  
Old 12-01-2006
You can use /tmp for your log file and you won't have access problems there.
So the script above would look like this
Code:
#! /bin/sh
#set -v

HOST='192.168.0.214 5021'
USER='user01'
PASSWD='user01'
FILE='/home/dude/file.txt'
FTPLOG='/tmp/ftplog'

echo "NOTE: check ftplog for connection info"
date > $FTPLOG

ftp -v -n $HOST >> $FTPLOG 2>&1 <<EOJ
quote USER $USER
quote PASS $PASSWD
debug
pwd
passive
pwd
put $FILE
ls
close
bye
EOJ
exit 0

Tornado
# 14  
Old 12-02-2006
MySQL

Thanks All Smilie
It worked fine.but please clear my concepts what is '2>$1' means?
what purpose is solved by writing debug?
and what does set -v do? How does it will affect the functionality if i wont include these parameters.

Please help me to clear my doubts.
Thanks a lot!!
Shiv@jad
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTPing files from unix server to windows server

Hi, Below is the script which ftps the file from unix server and putting in a different directory(but on unix server) How can i ftp the files from unix server and to place in a secure location on windows server? what changes needs to be done to the below script? How can this be... (1 Reply)
Discussion started by: venkatesht
1 Replies

2. UNIX for Dummies Questions & Answers

ftping a Zip file

i want to sftp a .zip file.when i am doing get abc.zip thenabc.zip is getting copied to my home folder. but on clicking abc.zip on my home folder to open it i am getting error message as "Unable to unarchive abc.zip into <homefolder> name" How to sftp the Zip file Thanks (1 Reply)
Discussion started by: bmrout007
1 Replies

3. UNIX for Dummies Questions & Answers

How to remove junk (^Ò) character while FTPing

Hi All, I have been trying to FTP some data files from Windows directory to a UNIX server. The txt file in the windows contails the following data: "111~XYZ~1~Contact person’s phone number~COMMENTS~~~~" but the same line is appearing as "111~XYZ~1~Contact person^Òs phone number~COMMENTS~~~~"... (8 Replies)
Discussion started by: vkumbhakarna
8 Replies

4. UNIX for Dummies Questions & Answers

Script for FTPing files to mainframe GDG

Hi, Request Unix gurus to kindly share a script which FTPs multiple files from Unix to a Mainframe GDG. The script should check for oldest file named as 'abc*.txt' in a directory '/dir/child'. FTP that file to MF, then remove the file from unix and then look for the next oldest file to be... (1 Reply)
Discussion started by: dsrookie
1 Replies

5. Shell Programming and Scripting

removing files after ftping

Hi All, I'm trying to write script to ftp some files and then need to remove these files from server. Is there any way to keep the condition that the file should be removed only after successfully transfered to the destinatino server? If in case, the file isn't been transferd, it should not be... (5 Replies)
Discussion started by: im_new
5 Replies

6. UNIX for Dummies Questions & Answers

ftping a file based in the size

Hi, I want to connect to a remote machine using FTP, check for the size of a file there. If it is 0 bytes, then there is no need to ftp else i have to ftp the file. Any help will be highly appreciated. (7 Replies)
Discussion started by: vikas.rao11
7 Replies

7. UNIX for Dummies Questions & Answers

FTPing from XP to Solaris

Hello. I'm new to Unix. I've got a SUN Ultra 10 running Solaris 5.7 and I'm trying to FTP to it from my XP PC. My PC has an IP address of 10.0.0.3 and a Subnet of 255.255.255.0. I'm connected to the Sun machine with a crossover cable. I type "ifconfig hme0 10.0.0.5" in a shell window (as... (3 Replies)
Discussion started by: dtferreira
3 Replies

8. Shell Programming and Scripting

FTPing from unix box to windows box.

Hi All, I need to know if it is possible ftping files from unix box to windows box . if yes , how ?. Is there any pre-requisits. Please tell me the steps, this is very urgent. Thnx Aru (8 Replies)
Discussion started by: aarora_98
8 Replies

9. Shell Programming and Scripting

Error in ftping script

Hi all , Can u please help me in this. I tried to just login server through the below script SERVER="Server_NAME" USER="i am user" PASSWD="mypassword" ftp -in $SERVER<<EOF user $USER $PASSWD mkdir Chanakya #To create directory with my name in $HOME ls > list put list bye... (5 Replies)
Discussion started by: Chanakya.m
5 Replies

10. UNIX for Advanced & Expert Users

FTPing over COM port ???

Hello. Can someone please help, or give me any advice. The company I work for has a unix machine and works over the com port rather than IP. We need to retrieve some files from it onto another unix machine and we are trying to get an ftp program to work, does anyone know any ftp programs that... (1 Reply)
Discussion started by: badge
1 Replies
Login or Register to Ask a Question