Automatically execute a command after PuTTY login and provide it with an input
The file that you pass using -m
switch can contain shell commands only. You cannot use it to provide an input to those commands. For that would would have to use remote shell features, like an input redirection – if you really need to use PuTTY.
But in general, to automate command execution, you should use Plink (part of PuTTY suite).
With Plink, you can do this:
(
echo input line 1
echo input line 2
) | plink.exe -ssh user@example.com -pw password command
Or an equivalent:
plink.exe -ssh user@example.com -pw password command < `input.txt`
Where the input.txt
contains the input for the command:
input line 1
input line 2
problem executing plink(putty) command
Try running it like this:
c:\plink.exe -l userId -pw psw remote_host C:\goto\test.bat
Related Topics
How to Avoid the Prompts While Using Azcopy on Linux in a Script
How to Cd into a Directory Using Perl
Core Dump Filename Gets Thread Name Instead of Executable Name with Core_Pattern %E.%P.Core
Are Pid-Files Still Flawed When Doing It 'Right'
Shutdown (Embedded) Linux from Kernel-Space
How to Make Static Linked Elf File to Load Ld_Preload .So
Catching a Direct Redirect to /Dev/Tty
How Can Linux Ptrace Be Unsafe or Contain a Race Condition
Scp: How to Find Out That Copying Was Finished
Linux Cant Find Dynamically Linked Applications
Lazarus: How to List All the Available Network Connection on a System
How to Catch Stdout Stream in Ffmpeg Then Pipe It to V4L2Loopback
Automatic Syntax/Headers in Vim for C++ Files