Command to automatically input password for pscp

batch-file, pscp

Solution

From putty documentation

5.2.2.6 -pw passw login with specified password

If a password is required to connect to the host, PSCP will interactively prompt you for it. However, this may not always be appropriate. If you are running PSCP as part of some automated job, it will not be possible to enter a password by hand. The -pw option to PSCP lets you specify the password to use on the command line.

Problem

I want to copy some file to a remote Linux system from my Windows PC using `pscp` (from putty). I wrote a small script that call the pscp commands in this way: ``` "C:\Users\hp\Desktop\pscp.exe" -scp C:\Users\hp\Desktop\scripts\* root@192.168.1.177:/root/scripts "C:\Users\hp\Desktop\pscp.exe" -scp C:\Users\hp\Desktop\scripts2\* root@192.168.1.177:/root/scripts2 pause ``` But when I launch this bat script, I'm asked to input the password, so I input the password manually. Is there a way to input the password automatically through the batch file?

Original source