Link to home
Start Free TrialLog in
Avatar of celtician
celticianFlag for American Samoa

asked on

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}'
Avatar of flow01
flow01
Flag of Netherlands image

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
Avatar of skullnobrains
skullnobrains

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.

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Usage:

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
Options:
  -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
Avatar of celtician

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Success!!

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 :)