check for file in another server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check for file in another server
# 1  
Old 07-05-2010
check for file in another server

Hi,

I want to check for existence of a file in another server. Is it possible to use if loop and check for the file existence after connecting via ftp.

After connecting via ftp in the script if I use if command it is throwing an error saying invalid command.if command is also not there in the list of commands that can be used in ftp. Is there any way i can achieve this.
# 2  
Old 07-05-2010
"if" is not for looping but branching.
As you said, ftp has a limited command set and does not offer logical branching and other scripting commands.

You could write a shell script that checks the output of a ftp command for example. Since checking if a file is present on another host using ls via ftp for example, will always return an exit code of 0 from your ftp command, so checking with $? is not possible. Though, ftp has it's own status codes which are 3 digits that you could parse, but I think that's rather awkward and not very reliable.

As ftp is not encrypted and sowith not secure, you should also think about the option of implementing the ssh suite, that include ssh, scp and sftp. It does a key based authentication so that you do not have to use clear passwords in a ftp-here script. Also all communication would be encrypted. There are countless guides on the www on how to setup ssh/scp/sftp without the need of passwords. You can also find plenty of threads inside this forum.

Checking if a file is present with ssh or scp from a script is rather easy, once it is set up.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File Check in remote server

Hi Experts, I need a script in which I need to scp a file /home/chandan/abc.txt to a remote server using scp. Then I need to check whether scp is successful or not. How am I going to write this code? My Server Name: myserver File Name On My Server: /home/chandan/abc.txt Destination Server... (3 Replies)
Discussion started by: ChandanN
3 Replies

2. Shell Programming and Scripting

Urgent: File Check in remote server

Hi Experts, I need a script in which I need to scp a file /home/chandan/abc.txt to a remote server using scp. Then I need to check whether scp is successful or not. How am I going to write this code? My Server Name: myserver File Name On My Server: /home/chandan/abc.txt Destination Server... (1 Reply)
Discussion started by: ChandanN
1 Replies

3. Shell Programming and Scripting

ssh to remote server and check if file exists

Hi everyone, I am trying to figure out a way to ssh to remote server and check if file exists, and if it doesn't I want to leave the script with an exit status of 5. I have the following that I am attempting to use, but it is not returning anything: check() { ssh ${SOURCE_SERV} "ls -l... (4 Replies)
Discussion started by: jimbojames
4 Replies

4. Shell Programming and Scripting

UNIX script to check file and start the informatica server

Hi Rockers, I hope u r dng good one. I have a one question is in unix with informatica . I need a unix script to check whether particular file exists in the folder , If it means we have a informatica server , so we can start the informatica server by accessing that file. Every week we have... (0 Replies)
Discussion started by: gurukrishnan
0 Replies

5. Shell Programming and Scripting

Check the size of the file on different server

Hello, I have two servers A and B, My script is written on Server A. I am picking up the file say "abc.txt" from Server B using sftp command and putting it in a directory at Server A. Now the catch is, If the file size of "abc.txt" is greater thn the available size on Server A, thn an email... (5 Replies)
Discussion started by: Prashant Jain
5 Replies

6. UNIX for Advanced & Expert Users

Check the size of the file on different server

Hello, I have two servers A and B, My script is written on Server A. I am picking up the file say "abc.txt" from Server B using sftp command and putting it in a directory at Server A. Now the catch is, If the file size of "abc.txt" is greater thn the available size on Server A, thn an email... (1 Reply)
Discussion started by: Prashant Jain
1 Replies

7. Shell Programming and Scripting

How to check whether file is exist on remote server

Hi all, I am new to UNIX Scripting. I would like to know how to check whether file is exist in remote server. I have google, but cannot find any solution that works. Currently my code is like this: if ; then echo 'data file exist' else echo 'data file not exist' fi Thanks in... (3 Replies)
Discussion started by: suigion
3 Replies

8. 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

9. Shell Programming and Scripting

How check for a new file on a ftp-server

Hi there, I want to write a linux shellscript that checks a specific folder on a specific FTP-server whether there are new files or not. If there are new files I want to download them to a local directory (to gain access for an local application to these files). The problem is that the files I... (3 Replies)
Discussion started by: monstrous
3 Replies

10. Shell Programming and Scripting

How to check the file status in a remote server?

Hi All, Thanks in Advance. My requirement is there are some data files to be updated(some times new files get created) regularly in server A, these files are to be updated to the server B(backup server) by using SCP, I have to write a script for this purpose, before copying the files to server... (3 Replies)
Discussion started by: rajus19
3 Replies
Login or Register to Ask a Question