How to check the file status in a remote server?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check the file status in a remote server?
# 1  
Old 04-27-2006
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 B, the current files in server B to be taken backup in backup floder of server B.

The problem is if the data file is new in server A it will just be copied to server B, if the data file is existing one and has updated in server A the script has to take the backup of existing file in server B & then copy the updated file from server A to server B.

After connecting to the server B using SCP how can I check whether the file is there or not (any conditional checks), then only it will be decided whether to only copy the file or taking the backup and then copy.

Your help will be greatly appreciated.

Thanks,
Raju

Last edited by rajus19; 04-27-2006 at 09:24 AM..
# 2  
Old 04-27-2006
any help pls...

Thanks in Advance
Raju
# 3  
Old 04-27-2006
Hi Raj,
One approach i can think of is to execuute the ls -l command on remote machine and get the list of files to Machine A.

STEP1: MachineA$ rsh MachineB ls /home/a2i8808 > /tmp/FromMachB.txt


Now check if the file you are ftping is in the list if so then again

You execute the remot command to keep the back

STEP2: MachineA$ rsh MachineB cp file1 file.backup

The STEP2 above should be in a loop for total number of files existing in MACHINEB which are same as Machine A.


STEP3: Now SCP all files.


Hope this helps.
# 4  
Old 04-28-2006
Hi Reddy,

Thanks for your help...

I will check it & let you know the status.


Regards,
Raju
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check via SSH and credentials if file on remote server exists?

Hi there, I am sorry to ask that kind of beginner thing, but all the code I found online didnt work for me. All I want to do is: Check via SSH if a File exists on my webserver. The SSH login has to be with username and password. So I would be very thankful if somebody could write the line.... (8 Replies)
Discussion started by: Jens885544
8 Replies

2. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

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

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

5. Shell Programming and Scripting

Unable to check if file exists on remote server using expect

Hi, I need to check if a file exists on remote server using expect. #!/bin/bash ip_addr=10.10.10.10 user=root passwd=Help filename=/root/test expect -c " spawn ssh -n -T -o NumberOfPasswordPrompts=3 -o StrictHostKeyChecking=no $user@$ip_addr expect \"*?assword:*\" send --... (6 Replies)
Discussion started by: temp_user
6 Replies

6. Shell Programming and Scripting

Find the remote server status.

Hi All, I would like to connect from "Instance A" to "Instance B" with the help of sftp. Where as Instance B is having clustered servers ( 2 servers pointing same instance ). Now, my question is before connecting to "Instance B" from "Instance A" how do know whether server is running or not.... (3 Replies)
Discussion started by: Girish19
3 Replies

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

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

9. Shell Programming and Scripting

Contantly check for file at the remote server and ftp when avaliable

Hello, I used the search engine but could not find the solution I am looking for. Probably its simple but I do not know the solution. My requirement is I ftp files every day in the morning from the remote server to the local machine. Now if the files are not there at the time I schedule the ftp... (2 Replies)
Discussion started by: kiran_418
2 Replies

10. Programming

How to check TCP server status

Please tell me according to C/C++ socket programming; how client can check whether server is running or not during TCP communication. (1 Reply)
Discussion started by: mansoorulhaq
1 Replies
Login or Register to Ask a Question