Copy file from unix box to another unix box


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Copy file from unix box to another unix box
# 1  
Old 04-28-2009
Copy file from unix box to another unix box

Hi,

I am new for perl scripting, I need a script to copy a log file /test/test_yyyymmdd.dat from one unix box to another unix box location /check/check1/ at daily 2:00AM, please let me know how to do that......

Regards,
Ann

Last edited by fabrine; 04-28-2009 at 04:45 AM..
# 2  
Old 04-28-2009
you can do it by shell script also

check the man pages of cron and crontab.

and hete is simple automated ftp script.

Quote:
#!/usr/bin/ksh
ftp -v -n "17.18.19.20" << cmd
user "username" "password"
cd /check/check1/
lcd /test/
bin
hash
put test_yyyymmdd.dat
quit
cmd
# 3  
Old 04-28-2009
copy file from unix box to another unix box

Hi,
Thanks for your reply.
I will run the cronjob from the server1 ,the script should copy the file test/test_yyyymmdd.dat from server2 and it should get copied to server1 check/check1 location.
I think your script whatever u mentioned its doing in reverse way...from server1 i m able to copy to server 2 but i need copy from server 2 to server 1 using script running from server1.Please let me know to do the same.
Thanks,
Ann
# 4  
Old 04-28-2009
oh!!
so u mean u don't want to "put" the file, but "get" it Smilie
There u go. Smilie
# 5  
Old 04-29-2009
Another query

Thanks it was working fine.
But the log file name is test_yyyymmdd.dat which is created daily in that /test folder, we need to get the last modified file i.e for example test_20080415.dat,test_20080418.dat are created in test folder it should copy the test_20080418.dat file to the server.

Regards,
Ann
# 6  
Old 04-29-2009
take a look at the man page for 'date'. You will be able to construct the date field of the filename, and then with that value you will be able to use the script above.
# 7  
Old 04-30-2009
Hammer & Screwdriver

Quote:
Originally Posted by fabrine
Hi,

I am new for perl scripting, I need a script to copy a log file /test/test_yyyymmdd.dat from one unix box to another unix box location /check/check1/ at daily 2:00AM, please let me know how to do that......

Regards,
Ann
-----------------
you can use also use remote copy
rcp -p server2:/test/test_yyymmdd.dat server1:/check/check1/

if you want to use the befits of date command, I recommend that you run the cron job at 23:59 to get the same date
or run abother cron job to get the date inside a file at any time during the day and run the copy cronjob at 2:00 AM and use the date from that file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX command to copy files from Windows to UNIX box

Hi Folks, I have a file name abc.xml in my windows machine at the location c:\ytr\abc.xml which I want to place at the unix box machine inside cde directory.. at the following location that is /opt/app/cde/ now the credentials of unix box are abc345 -->(dummyid) ftyiu88--->(dummy passwd) ... (4 Replies)
Discussion started by: punpun66
4 Replies

2. UNIX for Dummies Questions & Answers

Transferring the file from one UNIX box to another UNIX box

Hi Folks, I am using winscp to graphiclly move the files from one unix box to another unix box , let say one unix box crediantials is (These are dummy crediantials) xxx -->username yyy -->password and another unix box name is RRR -->username TTT -->password NOW i need to... (4 Replies)
Discussion started by: punpun66
4 Replies

3. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

4. UNIX for Dummies Questions & Answers

Copy file from Remote Unix box to windows machine

Hi I need to copy a file from the remote unix server to windows machine. I read lot of thrad but didn't worked out. Requesting all to please help. (2 Replies)
Discussion started by: sameerspice
2 Replies

5. Shell Programming and Scripting

how to compare all files in one unix box has been to copied to another unix box

Hi our unix admin has copied all files from one unix box to new unix box. We just need to confirm that all the file systems are copied properly. How to validate. (9 Replies)
Discussion started by: sravanreddym
9 Replies

6. UNIX for Dummies Questions & Answers

I need an scp command from a unix box to a windows box.

scp file="myfile.txt" todir="user@somehost:(M:drive:/somepath/)"/ Not sure I need it to go to a specific drive on the windows box (1 Reply)
Discussion started by: xgringo
1 Replies

7. UNIX for Dummies Questions & Answers

Running UNIX commands remotely in Windows box from Unix box – avoid entering password

I am able to run the UNIX commands in a Windows box from a UNIX box through "SSH" functionality. But whenever the SSH connection is established between UNIX and Windows, password for windows box is being asked. Is there a way to avoid asking password whenever the SSH connection is made? Can I... (1 Reply)
Discussion started by: D.kalpana
1 Replies

8. UNIX for Dummies Questions & Answers

Copy file from unix box to other

Hi all, I am new to UNIX. I have to copy a .ksh file from the production box PEDFX to test box BREMTX. Can anyone please suggest how I do this? I have CRT loaded on my system. (1 Reply)
Discussion started by: FORUM
1 Replies

9. UNIX for Advanced & Expert Users

How to FTP a file generated at UNIX Box to NT Box

Hi all, I am generating a file on the Unix machine , now i want to FTP the same file to the NT machine. how can i do that and the application currently upon which i am working is a JAVA based application. I need your help. regards Ruchir (2 Replies)
Discussion started by: Ruchir
2 Replies

10. UNIX for Advanced & Expert Users

VPN client (windows Box),and Server (Unix Box)

If I want to access unix box via VPN tunnel,from windows box. What sould I configure on the windows client PC, and what should I enable on the Unix Server box ? I am using Solaris V10 intel platform, and I am using windows XP, and 2003 for client (0 Replies)
Discussion started by: zillah
0 Replies
Login or Register to Ask a Question