Running shell commands

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
exheusden
Posts: 170
Joined: Fri Oct 09, 2009 5:03 pm
Contact:

Running shell commands

Post by exheusden » Mon May 03, 2010 12:09 am

Trying to run a few shell commands, using the shell function, as follows:

on mouseUp
put shell ("cd /Users/davidneale/Documents/Web\ stuff/David\'s\ Web\ stuff/Telenet\ Webspace/elvis/originals/eBook")
put shell ("ls")
get shell ("zip -q0X ROE.epub mimetype")
get shell ("zip -qXr9D ROE.epub *")
end mouseUp

I put the put shell ("ls") in as a check, when I couldn't get the rest to work. This line actually does return a directory list, but it shows only the contents of the Revolution directory (in other words, the cd command was not executed correctly).

Can anyone tell me what I am doing wrong?

RRobert
Posts: 151
Joined: Sat Feb 28, 2009 8:20 pm

Re: Running shell commands

Post by RRobert » Mon May 03, 2010 12:50 am

Set the defaultFolder property to the directory you like to work in.

Robert

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Running shell commands

Post by sturgis » Mon May 03, 2010 2:07 am

The reason its not working as you intend is because each shell call starts a separate shell instance. Setting the directory in the first shell call has no impact on the subsequent shells.

If you do as Rrobert says that becomes a non-issue.

To get a visual of how this works, try a simple script like

Code: Select all

put shell ("cd /Users/davidneale ; ls") -- switch dir, and get a listing in the same shell.
put shell ("ls") --get a listing in a seperate shell. Should be back at the runrev default location.

exheusden
Posts: 170
Joined: Fri Oct 09, 2009 5:03 pm
Contact:

Re: Running shell commands

Post by exheusden » Mon May 03, 2010 8:55 am

Thanks for your help. Works fine now.

Post Reply