Win 2 UNIX

Secure transfer between Windows and Unix

Hey Middleware Admin fans, here I am going to discuss about secure transfer for data/files between Windows and Unix systems. There are many ways to do this task. On your Windows desktop you can simply open SSH window and click on Yellow icon on top that had tag line as  "New File Transfer Window" authenticate and ftp/copying thats all done!  You have specific tools that enables you to transfer of files from Unix to Windows or vice versa, such tools are winSCP, psftp, pscp etc.

 

Scope for Automation

The task is repeatative then you will choose automation scripting with batch processing. After executing the automation job you must be be able to do secure transfer of There are server GNU opensourced utility tools are available to do this complex task.

1. WinSCP portables

2. PSFTP or pscp

 

Using WinSCP portables

Usually if you wish to do this task for single file and one time task nothing matter. The middleware secret here is

Your task would be either put or get files between Windows and UNIX boxes. To do this task you will be performing the following steps:

1. While doing ftp you need to open the session between Windows box to UNIX box.

2. Traverse to the desired directory location

3. Get the desired file(s) to destination location or put the file to remote location directory

4. Disconnect from the ftp connection by using bye or exit in the script.

Keeping all this commands into a file call it as batch file it can have extention as .bat or .cmd file.

Utility tools can be downloadable from

WinSCP : Download link

http://portableapps.com/apps/internet/winscp_portable

WinSCP must available in the environment the directory path must be in PATH variable.

setenv.bat

set datevar=%date:~10,4%_%date:~4,2%_%date:~7,2%

set log_file=C:\testlocation\log\myscript_%datevar%.log

set winscp_script_file=C:\testlocation\filetransfer.txt

set print_exe="C:\OpenOfficePortable\App\openoffice\program\soffice.exe"

set winscp_exe="C:\WinSCPPortable\App\winscp\winscp.exe"

Here in the above batch script you can have your own definitions for the installation paths and script paths.

Now let us see the filetransfer.txt contains the winScp file transfer logic(ftp commands) in the following script:

 

# Automatically answer all prompts negatively not to stall

# the script on errors

option batch on

# Disable overwrite confirmations that conflict with the previous

option confirm off

# Connect using a password

open user@Unixhostname.com

# Change remote directory

cd /unix/remote/location/

# Force binary mode transfer optional

option transfer binary

# Download file to the local directory

get *.doc C:\testlocation\

# Disconnect ftp session

close

# Exit WinSCP batch script

exit

 

Now its time to run your WinScp script it takes few options in the command line as given below:

%winscp_exe% /console /log=%winscp_log% /script=%winscp_script_file%

 

Using psftp utility

      

Now let us see the other alternative psftp utility usage for file transfer. You can get download psftp from the putty downlaod site links, however the following link is for your conveniance

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

You can start using the psftp command line utility as follows:

c:\psftp unixuser@yourhostname.com -pw urpassword -bc -b sendFiles.cmd

You can put the file from your Windows machine to a Unix machine with the following

Filename: sendFiles.cmd

cd /unix/remote/location

put test1.txt

bye

wget utility for Windows

http://users.ugent.be/~bpuype/wget/