View Full Version : How to writes a string of text to a window cmd.exe prompt?
jpdragon
10-20-2009, 10:08 PM
Is there a way to press a button and allow it to type a string of text or command to an external Unix telnet prompt or window command prompt?
Example:
after telneting to a Unix server at the prompt:>
I would like to execute the follow commands: cd /tmp and mkdir test.
Ulrich
10-21-2009, 07:16 AM
Telnet? You can use the Socket plugin to connect to the Unix server, send commands and receive answers back...
Ulrich
jpdragon
10-21-2009, 08:16 AM
Can autoplay Media Studio type keystroke on an external program like Unix windows or dos command prompt?
Sakuya
10-21-2009, 08:19 AM
You could give the window focus and then use ShadowUK's Send Keys freeware alternative.
Or if you look around there was a Standard I/O example that uses LuaCOM to create a process and then send it strings of data and get the data back.
jpdragon
10-28-2009, 02:13 PM
Can someone give me an example how to user LUACOM to do the following:
Open putty.exe
execute these commands:
ssh -l test -pw test www.google.com
cd /tmp
eject
exit
jpdragon
10-30-2009, 09:00 AM
I am clueless about LUACOM. Can someone give me a hints?
IdeasVacuum
10-30-2009, 03:37 PM
Take a look at the Help about File.Run:
sArgs = "ssh -l test -pw test www.google.com\n" .. "eject\n" .. "exit"
File.Run("putty.exe",sArgs, "/tmp", SW_SHOWNORMAL, true);
I have no idea if the above will work for you but a little bit of experimentation should get results.
Another approach might be:
File.Run("putty.exe","ssh -l test -pw test www.google.com", "/tmp", SW_SHOWNORMAL, false);
File.Run("putty.exe","eject", "/tmp", SW_SHOWNORMAL, false);
File.Run("putty.exe","exit", "/tmp", SW_SHOWNORMAL, false);
jpdragon
11-03-2009, 10:44 AM
I am manage to get this application work by using this method.
Create a button call "Eject" and put this code into the "OnClick"
-- Ask the user to turn off Caps Lock----------
Dialog.Message("Caps Lock Warning", "Please turn off your Caps Lock", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
File.Run("AutoPlay\\Docs\\putty.exe", "-ssh -l test -pw test www.google.com", "AutoPlay\\Docs", SW_SHOWNORMAL, false);
File.Run("AutoPlay\\Docs\\SendKeys.exe", "5 10 \"www.google.com- PuTTY\" \"pwd{ENTER} eject{PAUSE 2} {ENTER} {PAUSE 2} exit{ENTER}\"", "", SW_SHOWNORMAL, false);
Page.SetFocus("putty");
Remember to put putty.exe and SendKeys.exe to your Docs folder.
I have one question, how do I make a popup box to ask and allow to enter different site instead of www.google.com?
jpdragon you are doing so well ... if you think about it for a second though ...
You want a users Input right?... maybe a dialogue box ;) ;)
Use the help file, that is what is there for, good luck
jpdragon
11-04-2009, 02:27 PM
I finally got this working. I am very happy that I am manage to read through the help and figure it out myself.
I would like to share this with everyone that needed. This application allow you to launch putty.exe telnet to a server and execute whatever command from unix window automatically.
Put the code below to your "Onclick". Rember to put putty.exe and SendKey.exe to your Docs folder.
-- Start ask the user to turn off Caps Lock----------
Dialog.Message("Caps Lock Warning", "Please turn off your Caps Lock", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
-- End ask the user to turn off Caps Lock----------
-- Start ask the user to enter an IP address Script --
ask_ip = "";
-- Loop until a valid IP address is entered or the user cancels.
while (ask_ip == "") and (ask_ip ~= "CANCEL") do
-- Prompt the user to enter IP address
ask_ip = Dialog.Input("Enter IP", "Please enter WLG IP address:", "", MB_ICONQUESTION);
-- If the user does not enter any text, display an error message. The loop will continue from the beginning
if ask_ip == "" then
result = Dialog.Message("Error", "The IP address you enter could not be processed. Please try again.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
-- If the user entered a valid IP address and didn't cancel, continue to confirm IP address.
elseif ask_ip ~= "CANCEL" then
-- Ask user to confirm IP
nChoice = Dialog.Message("Confirm IP", "You are enter "..ask_ip.."! Is this correct?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON2);
-- If yes was chosen, exit the application.
if nChoice == 6 then
-- Start Loading Putty.exe and login to server --
result = File.Run("AutoPlay\\Docs\\putty.exe", "-ssh -l tpadmin -pw tpadmin "..ask_ip.."", "AutoPlay\\Docs", SW_SHOWNORMAL, false);
end
end
end
-- End ask the user to enter an IP address Script --
-- Start Loading SendKey.exe --
File.Run("AutoPlay\\Docs\\SendKeys.exe", "5 10 \""..ask_ip.." - PuTTY\" \"pwd{ENTER} eject{PAUSE 2} {ENTER} {PAUSE 2} exit{ENTER}\"", "", SW_SHOWNORMAL, false);
Page.SetFocus("putty");
-- End Loading SendKey.exe --
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.