I have a Powershell script that will automatically SSH to a Linux host (ESXI Server running Busybox) and will run a singular command (./my_script.sh
), which captures some network traffic on the ESXI server. However, this script waits for user input (CTRL + C) to exit the script.
I have tried using the Posh-SSH module (Invoke-SSHCommand -SSHSession $session -Command $command
) syntax as well as the Plink module (plink -batch *servername* -pw *userPassword* *command*
) but the commands always execute and return me back to the shell, they never wait for user interaction.
Of course, if I run it directly on the ESXI server the script will wait for the CTRL + C command to terminate.
Does anybody know of a workaround for this?
On option is the
timeout
command which shuold be present on , to set a runtime limit for whatever command you are running. For example, if you neededtcpdump
to capture packets for 20 seconds you could run:You can also specify a specific signal to send to the process with the
--signal
flag, if the command you are using has inconsistent behavior across different signals (view a list of signals wit kill -l`):