Download remote file from batch? (plink, putty, winscp...)

Id like to download a remote file, im able to get its name with a unix order, so i want to create a batch able to get remotely this file and download it locally, i would like to use plink but i'm open to other options.

this is the unix command that retrieves the file name to be downloaded

ls -alrt C*.TXT | tail -1 | awk '{print $NF}'
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I use ftp . check the internet for  'unix ftp script example' ,  
Modify it to a script taking as argument the filename
and call that ftpscript for each filename found in the batch
where is that file ? ftp server ? http server ?

wget will handle ftp and http nicely

scp or sftp will handle corresponding ways to download a file

 curl will handle all of the above and a few others

the samba package contains tools to download from a windows share

.... many other options depending on the URL
Download the Windows tool  "pscp"  (part of the PuTTY suite) from the same location where you downloaded "plink" from.


pscp user@remotehost:/remote/file  local_destination

In general:

PuTTY Secure Copy client
Release 0.63
Usage: pscp [options] [user@]host:source target
       pscp [options] source [source...] [user@]host:target
       pscp [options] -ls [user@]host:filespec
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -p        preserve file attributes
  -q        quiet, don't show statistics
  -r        copy directories recursively
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -P port   connect to specified port
  -l user   connect with specified username
  -pw passw login with specified password
  -1 -2     force use of particular SSH protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -batch    disable all interactive prompts
  -unsafe   allow server-side wildcards (DANGEROUS)
  -sftp     force use of SFTP protocol
  -scp      force use of SCP protocol
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

celticianAuthor Commented:
After checking, i think pscp is the solution i'm looking for, but how can i get it to work?

i tried to do some

pscp -P portNumber -pwd Password maquine:UserName:/directory/directory/resource.txt "c/destinationFolder"

and no success
If "maquine" is the host name of the remote Unix server:

pscp -P portNumber -pw Password UserName@maquine:/directory/directory/resource.txt "c:\destinationFolder"

"-P portNumber" is only needed if the ssh server on the remote Unix machine listens on a port different from the default port "22"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
celticianAuthor Commented:

Now i can go on with the script :))

thank you very much, it worked now by changing the username position in the full url string :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.