Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Copy the newest file from a different server to your home server. Post 302597063 by Lexx87 on Thursday 9th of February 2012 07:58:31 AM
Old 02-09-2012
Copy the newest file from a different server to your home server.

Hi all,

So I am on server 1, and I want to grab the newest file from a particular directory on server 2, and place this in a directory on server 1.

I am trying to use:
Code:
ls -tr | tail -1

This works, and gets me the newest file in a particular directory. Using svn `ls -tr | tail -1` etc I can grab the newest file and copy it somewhere else if the newest file is in the directory i'm currently in.

The problem is using ls -tr | tail -1 in an attempt on server 2, as ls seems to only look in the directory i'm currently in and not in another.

Is there a way I can use that command in a way like this example:
Code:
scp user@host:/directory $foo  where foo=`ls -tr | tail -1`

The $foo here only looks in the directory i'm in, not user@host etc.

Hope this ramble makes sense!!

Alex

---------- Post updated at 07:58 AM ---------- Previous update was at 06:25 AM ----------

Just to add to this.
Code:
[host1]  scp host2@IP:/home/b/files/reports/`ls -tr | tail -1`  host1@IP:/home/b/c/a/A/

Is what I am attempting.

The ls -tr | tail -1 looks in host1, rather than the latest file in the directory ending /reports/...I need a way to grab the latest file from /reports/ and place it in host1.

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 02-09-2012 at 10:54 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

home network - can you have a primary name server, or only a caching-only name server

i'm setting up a solaris 9 box to be my home network's DNS server. actually it's up and running, but it's set as a caching-only name server. can i set it up to be the primary name server? what are the advantages if i can set it up to be a primary name server vs. a caching only name server? (3 Replies)
Discussion started by: xyyz
3 Replies

2. Programming

Command for copy a file from one server to another server

hi, which Command is used for copy a file from one server to another server, please provide the syntax and give one small example... Thanks in advance sarwan (2 Replies)
Discussion started by: sarwan
2 Replies

3. Shell Programming and Scripting

copy files from remote server (B) to target server (A)?

Hi All, what is the comand to log off the remote server? I have 2 servers A, B. I need to find all files older than 7 days on server B and copy over to server A. My logic is: login the remote server: ================= ssh hostB cd /data/test find . -mtime -7 -ls | awk '{print... (4 Replies)
Discussion started by: Beginer0705
4 Replies

4. UNIX for Dummies Questions & Answers

To copy a file from one unix server to another unix server through scripts

I am getting the fallowing error when i am trying to execute the scp commomd in shell script warning: You have no controlling tty. Cannot read confirmation. warning: Authentication failed. Disconnected; key exchange or algorithm negotiation failed (Key exchange failed.). scp2: warning: ssh2... (1 Reply)
Discussion started by: manit
1 Replies

5. Shell Programming and Scripting

Copy file from one server to multiple server

can some one help me to write a shell script that copy one file from one server to multiple server ex:suppose i wnt to copy file abc.txt which is in server 1 to server2,server3,server4....:confused: (6 Replies)
Discussion started by: alokjyotibal
6 Replies

6. Shell Programming and Scripting

Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server. Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the... (1 Reply)
Discussion started by: richasmi
1 Replies

7. Shell Programming and Scripting

Copy folder and files from unix server to linux server

We would be migrating unix solaries to Linux redhat. Basically source is unix and target is linux. i would like to copy entire file system unix/source/* to target linux/souce/* but target linux has only folder setup so what ever files copied need to be placed in the linux server with same... (8 Replies)
Discussion started by: balajikalai
8 Replies

8. Shell Programming and Scripting

Copy files from Linux server to Windows server

Hi All, I am generating report in a Linux server and once the report is generated the report(.txt file) needs to be automatically saved in a Windows servers. So i am looking for a script to transfer the file automatically from Linux server to Windows server? Please advise. Thanks... (3 Replies)
Discussion started by: arunmanas
3 Replies

9. Shell Programming and Scripting

Shell script to copy a file from one server to anther server and execute the binary

Hi , Is there any script to copy a files (weblogic bianary + silent.xml ) from one server (linux) to another servers and then execute the copy file. We want to copy a file on multiple servers and run the installation. Thanks (1 Reply)
Discussion started by: Nawrajesh
1 Replies

10. Shell Programming and Scripting

Copy multiple .txt files from one server to another server

:wall:Hi all, I have two servers : server A and server B Weekly wise i use to receive files to server A to one particular location say /source/location . NOTE: In this location there will be other files also present other than these weekly arrival 18 files. My task : i need a... (7 Replies)
Discussion started by: karmegam
7 Replies
NWREVOKE(8)							     nwrevoke							       NWREVOKE(8)

NAME
nwrevoke - Revoke a Trustee Right from a directory SYNOPSIS
nwrevoke [ -h ] [ -S server ] [ -U user name ] [ -P password | -n ] [ -C ] [ -o object name ] [ -t type ] [ -r rights ] file/directory DESCRIPTION
nwrevoke revokes the specified bindery object with the corresponding trustee rights from the directory. nwrevoke looks up the file $HOME/.nwclient to find a file server, a user name and possibly a password. See nwclient(5) for more informa- tion. Please note that the access permissions of $HOME/.nwclient MUST be 600 for security reasons. OPTIONS
-h -h is used to print out a short help text. -S server server is the name of the server you want to use. -U user user is the user name to use for login. -P password password is the password to use for login. If neither -n nor -P are given, and the user has no open connection to the server, nwrevoke prompts for a password. -n -n should be given if no password is required for the login. -C By default, passwords are converted to uppercase before they are sent to the server, because most servers require this. You can turn off this conversion by -C. -o object name The name of the object to be added as trustee. -t object type The type of the object. Object type must be specified as a decimal value. Common values are 1 for user objects, 2 for group objects and 3 for print queues. Other values are allowed, but are usually used for specialized applications. If object type is not specified, object name is taken as NDS name. file/directory You must specify the file/directory from which to remove the object as trustee. If you specified -S, it must be fully qualified NetWare notation for DOS namespace. Otherwise it must be file or directory mounted to your system using ncpfs. Example: nwrevoke -S NWSERVER -o linus -t 1 'src:bsd_src' With this example, user linus is removed as trustee from the bsd_src directory on the src volume on server NWSERVER. nwrevoke -o linus -t 1 /home/vana/ncpfs/nwserver/src/bsd_src With this example, user linus is removed as trustee from the bsd_src directory. AUTHORS
nwrevoke was written by Volker Lendecke with the corresponding NetWare utility in mind. See the Changes file of ncpfs for other contribu- tors. nwrevoke 7/9/1996 NWREVOKE(8)
All times are GMT -4. The time now is 07:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy