I'm attempting to automate a few processes that occur over serial with command line and Putty.
I've read through the putty documentation but am unsure of what the syntax of the command file should look like. The device also requires you press "enter" to begin with your command.
Ultimately, I'd like to also add in "user prompts" in the script as well if possible. Any help would be much appreciated.
Related
I have a scenario where I need to run a shell command to a unix based appliance frequently from windows (linux could be an option). Because it's an appliance, it doesn't have the full breadth of capabilities that, say, Linux would have. I am using PuTTY to do this (I could use SSH from linux as well) which, I assume will work if I do something like "putty.exe -ssh -2 -l username -pw password -m c:remote.cmd hostname", but that only gets the command started. A user has to manually input the password - it cannot be done through command line, and I'm unaware of the capability to grab input from a file.
Is there a way by which I can automate this through the Putty?. By that I mean, I would like to send the input to the command in Putty like I was there, which would thereby be sent it to the appliance, not run a local script.
Thanks all in advance. Your input is greatly appreciated as we all may learn a little something.
Victor
For automation, use Plink (from PuTTY package). It's a console equivalent of PuTTY. So it supports input redirection:
(
echo password
echo some other input if needed
) | plink username#example.com command
some context first, Im using vba to automate putty into loging into many host with ssh retrieve info and save it.
I can do that currently, however, each time I execute a command, I have to set some waiting time just so the command is correctly executed and then I can execute next command. Is there any way to feeback from Putty output into vba so vba knows when to send next command? that would reduce execution time
sub retrievinginfo()
Lines to ssh open putty to X host
SendKeys "first command for putty session"
Application.wait Now+Timeserial(0,0,"estimated seconds") '<---- here the problem
SendKeys "second command for putty session"
end
Do not use PuTTY. That's a GUI application, not intended for automation.
Use Plink from PuTTY package. Plink is a console application intended for automation. It uses standard input/output, so that you do not have to hack sending of command by simulating keystokes.
Why do you even execute command this way? Why don't you specify a script file using -m switch?
See Automating command/script execution using PuTTY.
I need to SSH a remote machine and get onto the developer mode. To be specific, I want to execute the command 'Ctrl+gog' upon which I will be prompted for a password. I know how to execute the normal commands, for example chan.send("enable\n"). Please provide me with an answer.
chan.send("\x07\x0F\x07")
Above command worked fine for me.Just concatenate the Hexa equivalent for Ctrl-g,Ctrl-o,Ctrl-g which is, x07x0Fx07.
I've created a procedure on VBA (Excel) that restarts services on remote servers calling the command prompt and executing the "runas" command. I need to enter the command on the servers as administrator. So far it works fine but I don't want to have to type my password for each I want to run the command in. I know how I can automate the task using VBA and the Excel. What I don't know is how could I input my password on the command prompt using VBA?
Can anybody help me?
Thanks.
I've had all sorts of issues trying to convince runas to let me specify passwords from a program.
In the end, I tossed it and downloaded psexec from the Microsoft Windows Sysinternals site, which has other good stuff as well.
While many see this as a tool running remote programs, it can also be used quite happily to run local stuff under a different user name while allowing you to specify the password as a command-line argument, such as:
psexec -d -u USER -p PWD -w WORKDIR EXECUTABLE
You should be able to create a textbox control in VBA with the input mask set to password, this will allow you to enter the password in a non-viewable fashion.
Then you can just construct the psexec command and execute it from VBA, without having to worry about injecting the password into the process running runas.
I have created a VB.NET program using windows forms. The program runs on a remote PC and displays information on a screen. The computer does not even have a mouse or keyboard connected to it. The program shows the information based on the file that is loaded.
I want to be able to change this file remotely to another file that is already on the remote PC. I can't use a graphical remote desktop client as we have very limited bandwidth.
So, my idea is to change the file using the command prompt (I think I'll need something like SSH). I'm not sure how to do this. Should I use something like this and load DosModule first:
Module DOSModule
Public Sub Main()
Console.Write("First, start with Command Prompt processing ...")
Dim myWinForm As New WinForm
Application.Run(myWinForm)
End Sub
End Module
How would I then read commands that is send to the program? I also only want one instance of the program running.
Thanks
You have 2 options. The first is a custom program that WILL require some network programming, like it or not. I would suggest creating either a Command-Line batch file or else a PowerShell script, then creating a program to transfer the script to the remote computer and execute the script.
The second option and the one better suited for you would be to download an SSH server. An SSH server will essentially open a command window and pipe the input and output over to a telnet client running on your machine. If you are running a version of Windows Server, an SSH server comes with Windows Server. Otherwise, you can download one for free here: http://www.freesshd.com/
Once you install the SSH server, you simply use telnet, from a command prompt, to link up with your remote SSH server