简体   繁体   中英

Executing the windows batch file

What I am doing currently-

  1. Execute the shell script on MachineB from MachineA (Windows Environment).
  2. Then wait for the shell script to complete its task, in my case it will write the output to a text file.
  3. And after the shell script has completed all its task means it finished writing everything to a txt file, then copy that txt file to MachineA (Windows Environment) from MachineB .

So for this I wrote a Windows Batch file that will do the above task and it is working fine for me. Below is the Windows Bat file that I am using currently.

plink uname@machineB -m email.sh 
pscp  uname@machineB:/export/home/uname/jk_attachment22.txt C:\PLINK\foo.txt

But by using the above windows batch file, I need to type password two times which is pain, Firstly I need to type for the first line and then again for the second line.

My Question is-

So Is there any way I can run the above windows batch file by just typing password once at the command prompt. Any suggestions will be appreciated.

This is what I have when I was looking for /.ssh folder .

Update:

bash-3.00$ cd ~/.ssh
bash-3.00$ pwd
/home/uname/.ssh
bash-3.00$ ls -lt
total 2
-rw-r--r--   1 uname   gid-uname     489 Jul 26 18:55 known_hosts

So I need to make some other changes here?

I'd skip the password and auth with ssh key. http://www.debian-administration.org/articles/152

Use the -pw option in your command line utilities.

Let's say you name your batch file TWINKIE.BAT. At the command prompt, you'd type "TWINKIE password", where "password" is the actual password you want to use.

C:\>twinkie password

The "password" is passed into your batch file as the first command line variable, %1. Your batch file would be:

plink -pw %1 uname@machineB -m email.sh
pscp  -pw %1 uname@machineB:/export/home/uname/jk_attachment22.txt C:\PLINK\foo.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM