need to check the file using ftp in a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need to check the file using ftp in a shell script
# 1  
Old 05-08-2009
need to check the file using ftp in a shell script

i need to write a shell script..
connecting to another server using ftp and check whether the file ter.txt is exists there or not.
i have written scirpt partially,as i new to Unix.

ftp -inv $FTPHOST > $TEMPFILE1 2> $TEMPFILE1 << EOF
user $FTPUSER $FTPPW
binary
prompt
${CD}
ls *.txt /home/bin
close
bye
EOF
# 2  
Old 05-08-2009
if you have Python, here's an alternative
Code:
import ftplib
server="localhost"
user="anonymous"
password="test@hotmail.com"
def myfilter(line):
     if "ter.txt" in line: print "found: ",line     
try:
    ftp = ftplib.FTP(server)
    ftp.login(user,password)    
except Exception,e:
    print e
else:    
    ftp.cwd("/home/bin")
    ftp.retrlines('LIST',myfilter)
    ftp.close()

# 3  
Old 05-08-2009
need shell script in unix

Sorry yar,
I don't have python, I need shell script in unxi only.
Thnx
# 4  
Old 05-08-2009
you can use following code:

ssh user@hostname "find . -exec grep -q "ter.txt" '{}' \; -print"
# 5  
Old 05-08-2009
File server from one server to another server

When i used shh command it showing the error as follows.

The authenticity of host 'lpdma523.dev.ipc.us.aexp.com (148.171.30.205)' can't b
e established.

both the servers are in the same environment,they are connecting.. i don't know why it is not connecting through ssh. can any one suggest
# 6  
Old 05-08-2009
ftp -inv $FTPHOST > $TEMPFILE1 2> $TEMPFILE1 << EOF
user $FTPUSER $FTPPW
binary
prompt
${CD}
ls -ltr <your_server>/ftp_files.lst
close
bye
end

i=`grep -i "<wanted_file_name>" <your_server>/ftp_files.lst`
if test "i = "" ;
then
echo "file not found"
fi
# 7  
Old 05-08-2009
File server from one server to another server

Hi Shailesh,
Thanks for reply,
But here server means ip address or wat else?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to check a file

I'm required to write a simple shell script that when it runs it writes the output which is a simple barcode to a tmp flat file which I can do the bit I'm struggling with... The next time it runs I need to check the tmp output file to see if that barcode is in the output file and if it is send... (5 Replies)
Discussion started by: worky
5 Replies

2. UNIX for Dummies Questions & Answers

Need shell script to check file

Hi Experts, I am not good in writing script. Just stared.I am looking for shell script to check following parameters. 1) Number of files on remote Linux SUSE server.- Any directory and sub directory. 2) I should define number of files in script. Files should be variable. 3) Age of... (2 Replies)
Discussion started by: ApmPerfMonitor
2 Replies

3. Shell Programming and Scripting

How to check the duplicancy of file using shell script?

Hi all, i am getting the file through sftp from a location in the name of 20141201_file.txt (iam getting the file on daily basis with date appended at the beginning) so before going to my actual process ,i want to check whether today files and yesterday file are same or not(which i used to... (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

4. Shell Programming and Scripting

How to check file name format using shell script?

Hi, I am writting a script, which accepts input file as parameter. Input file name is aa_bb_cc_dd_ee.<ext> I need to check that input file name should be of 5 fileds. Please help me out. :confused: (7 Replies)
Discussion started by: Poonamol
7 Replies

5. Shell Programming and Scripting

Need to check for empty file in C shell script

I am running a C shell script. I have an output file from a previous step and I need to run "something" in the next step to check if the file is empty. If the file is empty, then the job script should finish EOJ. If the file is not empty then the job script should abend. Please help Thanks. (4 Replies)
Discussion started by: jclanc8
4 Replies

6. Shell Programming and Scripting

File System Check using shell script !!!

Hi Guys I m posing this new thread as I didnt get satisfactory result after running search here. My requirement is very simple (using shell script) I need to findout what all file systems are mounted -> Then I need check the health of that file system - by disk usage & by doing a simple... (8 Replies)
Discussion started by: csaha
8 Replies

7. Shell Programming and Scripting

Script to check file update on ftp server

Hi everybody, Is there a way to do a stat of files on a ftp server? I have a database which is populated by the contents of these files. I want to setup a crontab to check if there has been an update to these files. If the file has been updated I will download it and then update my database. ... (2 Replies)
Discussion started by: z1dane
2 Replies

8. Shell Programming and Scripting

shell script to ftp a file

Hi I would like to construct a UNIX shell script which when run, it will log on to an existing ftp server using a generic account and password, then list the files in a specific folder that begins with the string "abc" and particular date. The file names along with their creation date are then... (2 Replies)
Discussion started by: Manish4
2 Replies

9. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

10. AIX

how to check the existence of a file during ftp using korn shell?

i can able to transfer a file from build server(AIX)to webserver using ksh through ftp.my query is to check the existence of file while transfering from one server to other .i.e i need some command or script that checks the existence of file with same name in both server,within ftp syntax. ... (1 Reply)
Discussion started by: karthikprasathk
1 Replies
Login or Register to Ask a Question