command line options

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

command line options

Post by mwieder » Tue Apr 16, 2013 10:17 pm

I've been looking at the command line processor.

In the old cgi engine we had the ability to pass scripts to the engine from the command line and have the engine run them. This was locked down when the licensing mechanism changed to license the engine rather than the home stack.

I'd like to revive this feature to allow command line processing ala shell scripts, i.e.,

livecode < myscript.txt

I used to do this as an alternative to perl, ruby, etc. and I'd like to have it back.
I see the list of stack files getting processed from the command line in dskmain.cpp, but setting the return value of MCModeShouldLoadStacksOnStartup() in mode_development doesn't do the trick. I don't want to load a stack on startup anyway, I just want to execute a script text file.

Is there something simple that will allow input redirection to magically happen or is it more involved than that?

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: command line options

Post by LCMark » Tue Apr 16, 2013 11:20 pm

I think this still works with the standalone engine... It's only the ide ('development') engine that has the licensing code embedded.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: command line options

Post by mwieder » Tue Apr 16, 2013 11:32 pm

Hmmm... I put

Code: Select all

put the version
into file "test.txt", then replaced the community engine with the newly-build standalone engine. Running

Code: Select all

livecodecommunity.x86 < test.txt
just launched the IDE. Running

Code: Select all

livecodecommunity.x86 -ui < test.txt
gave me a segmentation fault.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: command line options

Post by mwieder » Tue Apr 16, 2013 11:39 pm

...and gdb says I crashed here

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
0x080a07e8 in MCScreenRect::evaluate (ep=..., p_working=false, 
    p_plural=false, p_effective=false) at ./src/funcs.cpp:4189
4189			t_rectangle =  p_working ? t_displays[t_index] . workarea : t_displays[t_index] . viewport;

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: command line options

Post by LCMark » Tue Apr 16, 2013 11:47 pm

Okay - I'll re-qualify the above with : it *should* work... I think you just found a bug :)

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: command line options

Post by LCMark » Tue Apr 16, 2013 11:55 pm

Actually - reading back - if 'livecodecommunity.x86' launched the IDE at any point, then that isn't the standalone engine.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: command line options

Post by mwieder » Wed Apr 17, 2013 12:00 am

I renamed it to make sure there weren't *those kind* of conflicts. But it's the standalone engine copied from the _debug folder after the build.

Update: the copy may have failed, so I redid the test, removing the existing engine first and then copying>
Now I get

Code: Select all

Startup error - failed to read standalone stack
when launching

Code: Select all

livecodecommunity.x86 < test.txt
with or without the -ui option

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: command line options

Post by monte » Wed Apr 17, 2013 12:48 am

Hmm... didn't the old CGI engine require something like this rather than just 'put the version'

Code: Select all

on startup
	put the version
end startup
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: command line options

Post by monte » Wed Apr 17, 2013 1:10 am

I think this still works with the standalone engine
Hmm... I think it was blocked from all engines when server came out... would have been too encouraging to just keep using CGI I guess. I think the last engine to support it was 3.5 ish
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: command line options

Post by mwieder » Wed Apr 17, 2013 2:17 am

Yeah... I'm hoping to get that put back.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: command line options

Post by LCMark » Wed Apr 17, 2013 9:12 am

Ah yes - I misremembered. The ability of the standalone engine to run a text script directly (as a parameter, don't think you could ever pipe one in as the stdin/stdout are directly passed to the stack/script for its use) stopped when standalones became proper executables and licensed based on the edition they were built in. I dimly recall providing a stack (to the improve-list at the time) you could build into a standalone that emulated the effect, but I might be mistaken.

In any case, the licensing requirement is obviously not there any more with community so it makes sense to reinstate this behavior (for both IDE and Standalone engines) - it also solves our build automation problem as part of the process (building the installers) is a LiveCode script based process that requires functionality in the IDE engine.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: command line options

Post by LCMark » Thu Apr 18, 2013 8:39 am

I had a look at this briefly yesterday and made some headway towards getting it to work - not sure if it will get into 6.0.1 but will put it on a branch at least if I get the patch finished.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: command line options

Post by mwieder » Thu Apr 18, 2013 4:09 pm

Yay! :D That's great news.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: command line options

Post by mwieder » Tue May 28, 2013 10:28 pm

@runrevmark - did this ever make it into a branch? I don't see it anywhere obvious. And it's still a current topic:

http://forums.runrev.com/viewtopic.php? ... 603#p76603

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: command line options

Post by LCMark » Wed May 29, 2013 10:14 am

@mwieder: It's a work in progress - it turned out to be a little fiddlier than I imagined... However, it's still being worked on :)

Locked

Return to “Engine Contributors”