Go to documentation repository
...
The run_cmd_timeout method is used to execute commands on the command line with the specified process termination timeout.
When invoking you call commands, the command line window does not open, the doesn't open; commands are executed in hidden mode.
...
Example 1. Run the curl utility and send a the POST request with the text "Hello" to the test URL https://postman-echo.com/post
| Code Block |
|---|
var s = run_cmd("curl --request POST --url https://postman-echo.com/post --data \'Hello\'");
DebugLogString(s); |
Example 2. Display the CPU usage on Chart 1, updating information on Timer 3.results of the SQL request.
| Code Block |
|---|
| Code Block |
var id = "1"; // id of the Charts object var timer_id = "3"; // id of the Timer object to trigger the script SLAVE_id = "DESKTOP-5397BVV"; // id of the Computer object if (Event.SourceType == "TIMERMACRO" && Event.Action == "TRIGGERRUN" && Event.SourceId == timer_id"1") { var date = Event.GetParam("date"); var times = Event.GetParamrun_cmd("time"); var cpu = "for /f \"tokens=2* delims=^,\" %k in ('typeperf \"\\Processor Information(_Total)\\% Processor Time\" -sc 1 ^| findstr \":\"') do echo %k"; var cpu_usage = run_cmd(cpu); var cpu_usage2 = cpu_usage.replace(/\"/g,""); var cpu_usage3 = cpu_usage2.replace(/\s/g,""); DebugLogString(cpu_usage3); DoReactStr("ANALOGCHART",id,"ANALOG_PARAMS","int_obj_id<"+id+">,parent_id<>,SLAVE_id<"+SLAVE_id+">,objid<"+id+">,chan<5>,core_global<1>,text<"+cpu_usage3+">, min_val<0>,max_val<100>,sensor_id<cpu_usage>,time<"+time+">,date<"+date+">sqlcmd -S MUKHAMED\\SQLEXPRESS2022 -U sa -P PSIM_default_DB_4 -d PSIM -Q \"SELECT id FROM dbo.OBJ_GRABBER WHERE parent_id='MUKHAMED'\" -o C:\\Users\\AxxonSoft\\Desktop\\result.txt"); } |