Trouble with Shell Command

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Trouble with Shell Command

Post by buchacho » Tue Oct 20, 2015 11:21 pm

I am trying to get some text output from a shell command. My script is something like this:

Code: Select all


put "C:/PROGRA~2/PICO~1/PICOS~1/Ps.com /a M.CSV?" into tCommand
put shell (tCommand) 
When I run the script, the shell window opens, but there is no output (just a blinking cursor). I have to close the window in order for the LiveCode script to be able to terminate. If I run the command in the shell directly, it works fine and outputs a couple lines of text. I was wondering if the slash in the "/a" part is the issue, so I put the command in a batch file and ran that, but I got the same result. I tried adding an extra forward slash (//a), but the script ended up launching the Ps.com GUI. I am running Windows 7 and wondering if there is some kind of permissions issue. I ran LiveCode as an administrator, but it still does not work. Any ideas?
Last edited by buchacho on Tue Oct 20, 2015 11:39 pm, edited 1 time in total.

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Trouble with Shell Command

Post by SparkOut » Tue Oct 20, 2015 11:30 pm

I can't play with tests at the moment, but try wrapping the whole command line in another set of quotes, so that the arguments are passed as part of the shell command, as in
get shell(quote & tCommand & quote)
put it

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Trouble with Shell Command

Post by buchacho » Tue Oct 20, 2015 11:37 pm

SparkOut wrote:get shell(quote & tCommand & quote)
put it
Thanks for the suggestion. If I do this, the response I get is "The system cannot find the path specified.".

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Trouble with Shell Command

Post by FourthWorld » Wed Oct 21, 2015 12:33 am

Is that second argument a file path? If so it may need quotes around it.

Also, you can hide console windows by setting the hideConsoleWindows global property to true before calling the shell function.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Trouble with Shell Command

Post by buchacho » Wed Oct 21, 2015 12:40 am

FourthWorld wrote:Is that second argument a file path? If so it may need quotes around it.
I believe it is a command. If I try "C:/PROGRA~2/PICO~1/PICOS~1/Ps.com /a ?" I get the same non-result. With that command, it should output a list of commands.
FourthWorld wrote:Also, you can hide console windows by setting the hideConsoleWindows global property to true before calling the shell function.
If I do that, I cannot close the window and then have to open the windows Task Manager to kill the process.

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Trouble with Shell Command

Post by buchacho » Fri Oct 23, 2015 12:11 am

Is there any way I can monitor what is happening? I am stuck here.

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Trouble with Shell Command

Post by buchacho » Wed Oct 28, 2015 8:46 pm

Any way I can troubleshoot what is going on with the cmd shell? As far as I can tell at the moment, there is a bug with the shell command.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Trouble with Shell Command

Post by FourthWorld » Wed Oct 28, 2015 9:24 pm

What is the string returned from the function?
Does the command work in Window's shell?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Trouble with Shell Command

Post by buchacho » Wed Oct 28, 2015 10:32 pm

FourthWorld wrote:What is the string returned from the function?
Unfortunately no string is returned when I attempt to run the test.bat file with the LiveCode shell command. There is just a blinking cursor, like it is waiting for something to happen.
FourthWorld wrote:Does the command work in Window's shell?
Yes, the output from the test.bat file looks something like this:

Code: Select all

2015-10-28, 02:12 PM 
0ms: Measurements.CSV?
A,AC RMS,565.7 mV,565.7 mV,565.7 mV,565.7 mV,94.19 æV,16,WholeTrace,
A,Maximum,800.2 mV,800.2 mV,800.3 mV,800.3 mV,103.9 æV,16,WholeTrace,

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Trouble with Shell Command

Post by buchacho » Wed Oct 28, 2015 10:39 pm

I also tried a .bat to .exe converter to create a test.exe to call from LiveCode. It works when I double-click the .exe in the Windows GUI, however, shell or launch LiveCode commands do not work with the "test.exe" either. For some reason the way LiveCode makes the shell or launch call is not allowing the underlying command to execute.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Trouble with Shell Command

Post by FourthWorld » Wed Oct 28, 2015 11:25 pm

It might be a bug in LC, or it might be something specific to that program.

You might consider filing a bug report at http://quality.runrev.com/

You can also try "open process "<command>" for neither", whether "neither" means not waiting for reads or writes.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

5imon
Posts: 19
Joined: Fri Nov 22, 2019 8:09 pm

Re: Trouble with Shell Command

Post by 5imon » Tue Dec 08, 2020 2:47 am

I just ran into the same problem as buchacho and spent the better part of a few hours debugging it. I finally got it to work when formatted as the following:

Code: Select all

put "cd C:/Users/5imon/AppData/Local/HaptUX/ExManCmdWin/" into thePath
put "& ExManCmd /list" into theArgs
get shell(thePath & theArgs)
That works 100%.

However, if theArgs has multiple args then a peculiar quirk happens ...

Code: Select all

put "cd C:/Users/5imon/AppData/Local/HaptUX/ExManCmdWin/" into thePath
put "& ExManCmd /list all" into theArgs
get shell(thePath & theArgs)
... the Command Prompt app launches and makes itself visible for a few seconds (all the while with a blinking prompt), then disappears and Livecode completes get shell() as expected.

I'm only replying to this post with a solution because I want to also ask why the command prompt is being launched (I'll do that in a separate subject to avoid high jacking this one).

If you can live with seeing the command prompt launch for a split second then the above should work for you.

Post Reply

Return to “Windows”