FTP from Widows to UNIX system - how to? ( was To not to duplicate)


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers FTP from Widows to UNIX system - how to? ( was To not to duplicate)
# 1  
Old 01-22-2016
Code FTP from Widows to UNIX system - how to? ( was To not to duplicate)

Dear team , thanks for your support. I am trying to not to duplicate a thread if one is already there for what I am looking, which I am not able to figure out. Is it OK if I post the post the following question in new thread.
---
Moderator's Comments:
Mod Comment What follows was in blue.. we are to avoid using colours as we want people to use code tags


" I am having little trouble to create a script to get file from UNIX box to Windows through ftp. Right now I amusing the following script to pick specific file.
Code:
 FTP open <remote server>
'login'
'pwd'
cd 'files path in remote server '
get 'DAILYFEED_20151202_163216.txt'

How to pick the latest one if there are many files with the similar name and time stamp is different in file name.

Ex: List available is
Code:
'DAILYFEED_20151202_163236.txt
'DAILYFEED_20151202_163436.txt
'DAILYFEED_20151202_193226.txt
'DAILYFEED_20151202_193211.txt
'DAILYFEED_20151202_193216.txt
'DAILYFEED_20151202_183216.txt
'DAILYFEED_20151202_173216.txt
'DAILYFEED_20151202_163222.txt
'DAILYFEED_20151202_163220.txt
'DAILYFEED_20151202_163219.txt
'DAILYFEED_20151202_163218.txt
'DAILYFEED_20151202_163217.txt
'DAILYFEED_20151202_163216.txt

I need to pick and pull
Code:
'DAILYFEED_20151202_193226.txt

Kindly help me with the solutin. Thanks in advance.

Sai

Last edited by vbe; 01-22-2016 at 12:44 PM..
# 2  
Old 01-22-2016
i would do it in 2 passes. first connect and issue an ls -l command. save the output to a file, then examine the file and decide which file(s) you want and re-connect to retrieve.d
# 3  
Old 01-22-2016
jgt, what I understand is write 2 scripts one for selecting the latest file name and the other for moving the file. Is it correct.

can you please help me with the sample script, if possible.
# 4  
Old 01-22-2016
I'm a little confused. Your title of this thread says FTP from Windows to Unix but in your post#1 you say

"I am having little trouble to create a script to get file from UNIX box to Windows through ftp."

So which direction are we going in?
Is the script going to run on the Unix side or the Windows side?
Is FTP going to "put" or "get"?

Please clarify.
# 5  
Old 01-22-2016
Either way;
Code:
ftp host >filelist
user
password
cd 'filepath'
ls
quit

You should now have a list of all the files on the source system, in the local file filelist.
You should now examine filelist to decide which file(s) you want to move and write them to a new file looking something like
Code:
cd pathtofile
get DAILYFEED_20160121.txt
quit

then re-connect
Code:
ftp host <new_file

If you are running the ftp client on the unix system, then you can create a .netrc file in the home directory of the user running these scripts so that you do not need to enter the user and password.
Sample script to select files:
Code:
count=0
echo "cd pathtofiles"
while read filename
do
    if [ $filename = "some criteria" ]
    then
     echo get (or maybe put) $filename
     count=`expr $count + 1`
     fi
done <filelist
echo "quit"
if [ $count -eq 0 ]
   then
   exit 1 
   #no files selected
else
    exit 0
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Migrating jobs from COBOL Mainframe system to UNIX system

In a nutshell requirement is to migrate the system from mainframe environment to UNIX environment (MF cobol would be used I guess). I have not much of idea in this field. I need to do some investigation on following points - - Ease of conversion - Known Data compatibility issue - Issue in... (9 Replies)
Discussion started by: Tjsureboy4me
9 Replies

2. UNIX for Dummies Questions & Answers

Unix System Programmer Vs. Unix System Administrator

Hi friends, I hope you are all fine and doing well. First of all, let me say that I love Unix with passion. But I have one query in my mind that is bothering me. What should I do, Unix System Administration or Unix System Programmering. Could you please tell me the difference between the two. And... (3 Replies)
Discussion started by: gabam
3 Replies

3. UNIX for Dummies Questions & Answers

Duplicate column in unix file

Hello, I have a fixed width unix file with 2 columns containing the following data ZTXX_CTBR1-ZBRAN1 ZTXX_CTBR1-ZBRAN_DESC 01 CASH & CARRY 02 DRUGSTORE - RX 04 ... (4 Replies)
Discussion started by: chumsky
4 Replies

4. Windows & DOS: Issues & Discussions

script to change widows update permissions

I want to allow windows update when ordinary users are logged on, I'm pretty sure that adjusting the permissions registry entry HEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate to allow acces to all domins users does the trick. I already have a logon.bat that runs at... (0 Replies)
Discussion started by: barrydocks
0 Replies

5. UNIX for Advanced & Expert Users

user is not able to FTP to system.

Helo, I have created one group called RBAC.(roll back access control) Now when I created user of RBAC its entry in /etc/passwd file is given below: roleadm:x:120:109:RBAC User:/home/pds_RBAC:/bin/false I have keep at the end /bin/false because I dont want to give direct login to the user... (2 Replies)
Discussion started by: amitpansuria
2 Replies

6. UNIX for Advanced & Expert Users

MVS->Unix FTP : Using chmod as part of FTP.

We are transferring file from mainframes to unix, & in FTP process itself we would like to set access rights for unix machine. Has anyone used chmod command in association with site command in ftp? How it should be used? Thanks in advance. (1 Reply)
Discussion started by: videsh77
1 Replies

7. Filesystems, Disks and Memory

How to duplicate a drive in Unix?

I have a drive that I need to make a sector-by-sector or exact image copy of. In Windows, I use a program call Ghost by Symantec, but the version I have does not support Unix. Does anyone know of a good product for Unix? Thanks, Brett Gibson Gibson Teldata, Inc. (13 Replies)
Discussion started by: bgibson
13 Replies

8. Shell Programming and Scripting

FTP script to FTP file to UNIX - Solaris

Hello, A couple of times per week, i receive emails notifications when files are available for processing. Currently i read these eamails with a java program and store the attachement on my C: drive and would now like to generate a PC script to send this file name up to UNIX-Solaris and... (3 Replies)
Discussion started by: bobk544
3 Replies

9. Solaris

Secure FTP Problem using Sun SSH on Client system F-Secure on Server system

I am using shell script to do secure ftp. I have done key file setup to do password less authentication. Following are the FTP Details: FTP Client has Sun SSH. FTP Server has F-Secure. I am using SCP Command to do secure copy files. When I am doing this, I am getting the foll error scp:... (2 Replies)
Discussion started by: ftpguy
2 Replies

10. Programming

Need help about realizing an ftp-like system.

Hi people! As you can read in the subject, I have a project at the University that requires me to realize a ftp-like through the sockets, in C. This is what I've been told so far, and since I'm studying Unix now for the first time I have little idea of where to start. Does anybody know of a... (1 Reply)
Discussion started by: OpSys
1 Replies
Login or Register to Ask a Question