PDA

View Full Version : FREE CommandLine Action Plugin



reteset
11-01-2009, 05:58 AM
Hi everyone
this is a commandline plugin that executes DOS commands through system's CMD.exe and retruns the output as a lua table

it also supports your custom commandline applications as long as you use a file path

i built this plugin by member requests

there is only one action with two arguments

there is no much difference between File.Run() that you familiar

table = CommandLine.Execute((string) Commandline,(number) TimeOut);

Commandline : a commanline string Ex: "ping 127.0.0.1"
TimeOut : (ms 1000 = 1 second) the time out , if you want to terminate a executed commanline application then a certain time period you can specify it here
if you set the timeout 0 then action will wait until commandline app. exits

Return Value : if an error occurs the return value is nil
the return value is a table otherwise , and the table indexes are
(string) StdOut , (string) StdError , (number) ExitCode

Execute a Standard MS DOS command :


StatusDlg.Show(MB_ICONNONE, false);
StatusDlg.ShowProgressMeter(false);
StatusDlg.SetTitle("Working..");
StatusDlg.SetMessage(" Executing Command...");

tblResult = CommandLine.Execute("ping 127.0.0.1", 0);

if (tblResult ~= nil ) then

Input.SetText("Input1", tblResult.StdOut);
Input.SetText("Input2", tblResult.StdError);
Input.SetText("Input3", tblResult.ExitCode);

StatusDlg.Hide();

else

StatusDlg.Hide();
Dialog.Message("Error", "Failed To Execute command Line..", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

end


Execute your own commandline application:


StatusDlg.Show(MB_ICONNONE, false);
StatusDlg.ShowProgressMeter(false);
StatusDlg.SetTitle("Working..");
StatusDlg.SetMessage(" Executing Command...");

local sz_commandline = _SourceFolder.."\\AutoPlay\\Docs\\ConsoleTest.exe Hello World \"NonBreaked Hello World\""

tblResult = CommandLine.Execute(sz_commandline, 0);

if (tblResult ~= nil ) then

Input.SetText("Input1", tblResult.StdOut);
Input.SetText("Input2", tblResult.StdError);
Input.SetText("Input3", tblResult.ExitCode);

StatusDlg.Hide();

else

StatusDlg.Hide();
Dialog.Message("Error", "Failed To Execute command Line..", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

end

Screenshot : Click Here (http://www.amsplugins.com/screenshots/CommandLine.jpg)

Download : Click Here (http://www.amsplugins.com/details.asp?ID=95&CID=1)

Sakuya
11-01-2009, 06:08 AM
Useful if I ever return to AutoPlay scripting.

longedge
11-01-2009, 09:02 AM
Thank you very much Reteset. I usually stay with native AMS but this one is too good to miss :yes.

Centauri Soldier
11-01-2009, 09:28 AM
Thanks so much Reteset, I was working on one of these (based on one of sside's dlls) but now I don't have to finish it...:D.

It couldn't have come at a better time either, I have been using created batch files in one of my projects to run the commands; this plugin will solve that work-around.

Nice job and thanks again for the contribution. :yes

rexzooly
11-01-2009, 09:55 AM
Once again a great tool thanks :yes hope i get chance to use it in the future :D

DaSoulRed
11-01-2009, 01:26 PM
Once again a great tool thanks :yes hope i get chance to use it in the future :D

I wonder if u will change your undernick soon.
That will differece you from the rest off us... rigth... a new level rigth...

Nice to se you Rex, Bye.

johnraus
11-01-2009, 02:39 PM
Thnx, very usefull :D
(like sside's DLL but without the .Net dependency :cool)

jassing
11-01-2009, 05:22 PM
does this work if you have standard output redirected to a file? ie: does it trap stderr output to the table and leave stdout into a redirect file?
or is a wrapper for calling the command interpreter and redirects output?

Dermot
11-01-2009, 07:23 PM
At least in my tests, if the commandline app as an option to output to a file, it will still output to the file as well as return the output in the returned table.


does this work if you have standard output redirected to a file? ie: does it trap stderr output to the table and leave stdout into a redirect file?
or is a wrapper for calling the command interpreter and redirects output?

reteset
11-02-2009, 11:46 AM
does this work if you have standard output redirected to a file? ie: does it trap stderr output to the table and leave stdout into a redirect file?
or is a wrapper for calling the command interpreter and redirects output?
yes it does so ,
but why did you want to redirect output to file ??
whereas you already have that data

i made this plugin to save you from use of text file redirection :p
also this plugin makes necessary CODE page conversion too
of course if you work for only english systems this is not a problem
but in non-english operating systems you need to make some text conversions to avoid unexpected sysbols

if you want to have both ,you could just use something like below



tblResult = CommandLine.Execute("SYSTEMINFO",0);

if (tblResult ~= nil ) then

if (tblResult.ExitCode == 0 ) then -- 0 means success in MS DOS

TextFile.WriteFromString("C:\\MyFile.txt", tblResult.StdOut, false);

else

Dialog.Message("Error", tblResult.StdError, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

end

reteset
06-01-2010, 02:41 PM
CommandLine Action Plugin Has Been Updated To AutoPlay Media Studio 8

More Info Can Be Found Here (http://www.amsplugins.com/details.asp?ID=95)

analogscott
12-20-2011, 11:20 AM
Is there still a 7.5 version?

reteset
01-02-2012, 01:52 PM
you are in your lucky day , here it is