Thursday, June 30, 2016

Copy files from linux to windows using PSCP (putty)


This is a  simple batch script that will prompt you for the remote file location and when  provided will copy file from remote location to local destination directory (will prompt for local dir too ).
This script will need putty pscp executable file and you will need to configure the create and save connection to the remote hosts. As below

You can download putty from here






-- Script starts here 
-- copy below to file and save it as batch file Ex:  filename.bat 



@ECHO off

SET /P REMOTE_FILE=ENTER FULL PATH TO REMOTE FILE:
SET /P LOCAL_FOLDER=ENTER PATH TO LOCAL FOLDER:
SET PATH=C:\Program Files (x86)\PuTTY;%PATH%
IF "%REMOTE_FILE%"=="" GOTO Error1
IF "%LOCAL_FOLDER%"=="" GOTO Error2
ECHO EXECUTING :
ECHO pscp username@Linux01:%REMOTE_FILE% %LOCAL_FOLDER%
pscp username@Linux01:%REMOTE_FILE% %LOCAL_FOLDER%
GOTO End
:Error1
ECHO You didn't enter REMOTE_FILE details!!
:Error2
ECHO You didn't enter LOCAL_FOLDER details!!
:End




Sample output :

C:\Windows\System32>pscp_script.bat
ENTER FULL PATH TO REMOTE FILE: /u01/app/oracle/dpump/test1.log
ENTER PATH TO LOCAL FOLDER: C:\test
EXECUTING :
pscp username@Linux01:/u01/app/oracle/dpump/test.log C:\test
test.log                  | 18 kB |  18.5 kB/s | ETA: 00:00:00 | 100%

No comments:

Post a Comment