Need to copy the latest file from Unix server to Shared folder

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Need to copy the latest file from Unix server to Shared folder
# 1  
Old 10-06-2011
Need to copy the latest file from Unix server to Shared folder

Hi All,

One job in unix server will generate .csv files daily. I need to copy the latest of these .csv file from the unix server to the shared drive/folder in windows through unix script. My shared folder will look something like
W:\some folder(for example). Could any one of you please help me out with the unix script which will transfer the latest file from unix server to shared folder.

Your help will be much appreciated.

Regards,Jaya
# 2  
Old 10-06-2011
For starters, how is the data accessed? Samba? FTP? SCP?

If it's really a windows file share(samba), then there's things outside the script you'll need to set up first. You'll need to get the directory mounted on your server. How to do that depends on what your server actually is.

Last edited by Corona688; 10-06-2011 at 11:46 AM..
# 3  
Old 10-06-2011
Hi Thanks for your quick reply,

The data is accessed through FTP.

---------- Post updated at 09:57 AM ---------- Previous update was at 09:46 AM ----------

As i am new to unix script, can you please tell me how to mount the directory to the unix server?
For you info, i used the below script.
Code:

#!usr/bin/ksh
lcd /home/manuownr/temp
USER xxxx
PASSWD xxxxx
prompt n
mput *.*
cd \\auviccf03\temp
exit 0

Here home/manuownr/temp is the unix path(Source) and \auviccf03\temp is the shared drive (Destination)
# 4  
Old 10-06-2011
Okay. And what's your UNIX server?

FTP is not a Windows file share. If it's FTP, you can use ftp and not mount anything.

That KSH script is full of FTP commands and won't work, because FTP is not KSH. You have to feed them into the ftp command, which is different on different versions of UNIX. What's your system?

"\\auviccf03\temp" is probably not a folder you can CD to, you'll need the actual folder not the network one. If you only have the network one then it's not FTP after all.

You've also got the mput before you change directory, which is probably not what you want.

Code:
#!/bin/ksh

ftp <<EOF
        lcd /home/manuownr/temp
        USER xxxx
        PASSWD xxxxx
        prompt n
        cd c:\path\to\file
        mput *.*
        quit
EOF


Last edited by Corona688; 10-06-2011 at 12:10 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy one file from a server to a local folder

Hi, Is there a way I can copy a file from a server to a local folder (i.e. My Documents)? can it be done by scp? I tried this but it just rename the file as the folder it has to be transferred at. scp -r name@some_server:/home/user/file.txt 'somehere\home\home_dir' Thanks. (4 Replies)
Discussion started by: erin00
4 Replies

2. Shell Programming and Scripting

Copy file from UNIX to shared location

Hi All, I want to transfer file from UNIX to shared locataion . Shared location doesn't resides on my system. Can somebody tell me is there any way i can transfer file from UNIX to shared location without using any tool WINSCP. Thanks, Amit (1 Reply)
Discussion started by: Amit786
1 Replies

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

4. UNIX for Dummies Questions & Answers

Copy the latest (last file) in given folder

#!/bin/bash for i in {1..1536..1} do #find /home/test/Desktop/up111/workplace/Malware/$i/logs for a in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do #max=a for b in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do ... (4 Replies)
Discussion started by: upvan111
4 Replies

5. Shell Programming and Scripting

Need a script to fetch file from shared folder to unix box

Hi All, We have a requirement of pulling a file from shared folder to our unix box(Our application Servers). The Shared Folder and the servers are in teh same domain for eg UK domain For this purpose I got information like if in both source and destination ftp is enabled we can fetch the... (2 Replies)
Discussion started by: dhivya.enjoy
2 Replies

6. Shell Programming and Scripting

How to find the latest modified file from the unix server.

hi Friends, In my directory i have some files. I need to find out latest modified file. Please help me. Sreenu. (2 Replies)
Discussion started by: sreenu80
2 Replies

7. Shell Programming and Scripting

copy the latest file in the remote server's directory

Hi Expert Team, I performed the below piece of code to copy the latest file in the remote server's directory to the same server's other directory. But it is not working properly. How can i handle this? Can you please help me..? ssh ${REMOTE_USERID}@${REMOTE_HOSTNAME} "cp -p `ssh... (3 Replies)
Discussion started by: spkandy
3 Replies

8. UNIX and Linux Applications

Copy folder and its contents from HP Unix server to RH Linux

I am trying to copy a folder and all its contents from HP Unix box to RH linux, using the following. rsync -avz -e "ssh" /users/www/webroot/docFiles/Division/Ctry ftpuser@10.4.xxx.yz:/data/webroot/development/contentfiles/webroot/docFiles/Division/Ctry/QAfiles And it throws a consistent... (2 Replies)
Discussion started by: FanTom
2 Replies

9. UNIX for Dummies Questions & Answers

Copy the latest file from a folder

Hi, I have a problem. I have some text files in a folder. The names can be like: emp_20080307053015.dat emp_20080306053015.dat emp_20080305053015.dat emp_20080304053015.dat The date format appended is like yyyymmdd and timestamp. What i need is i have to copy the latest file every... (3 Replies)
Discussion started by: Aswarth
3 Replies

10. UNIX for Dummies Questions & Answers

copy file from UNIX to shared directory

Hi, I want to copy a file from unix machine to a shared windows directory. i tried using the ftp command but i was able to transfer the file only to my local directory. Is there any way we can transfer/copy the files from unix to windows shared directory.......... Please help. Thanks (5 Replies)
Discussion started by: sireesha15
5 Replies
Login or Register to Ask a Question