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

Posted on 2013-08-29
Medium Priority
Last Modified: 2013-08-30
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}'
Question by:celtician
LVL 21

Expert Comment

ID: 39450473
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
LVL 27

Expert Comment

ID: 39450495
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
LVL 68

Expert Comment

ID: 39450622
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 39450871
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
LVL 68

Accepted Solution

woolmilkporc earned 2000 total points
ID: 39450889
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"

Author Comment

ID: 39452773

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question