MAC Shell command

Asked by Jeff_Vallis

MAC user
Trying to find syntax to execute a command from Sikuli
Test
run("env > findthisxxxx")
Result
[error] SyntaxError ( "mismatched input '_try_run' expecting LPAREN", )

what I am really trying to do is
either
1. Find out where it is being run - and create an exectable file there and use run(mycommand) there
or
2. Run a multiline command
example
export PATH=/opt/local/sbin:$PATH
export PATH=/usr/bin:$PATH
export PATH=/usr/sbin:$PATH
export PATH=:/bin:$PATH
export PATH=/usr/sbin:$PATH
export PATH=/opt/X11/bin:$PATH
export PATH=/opt/local/bin/:$PATH

convert /Users/test/Desktop/'Tynon Auto'/Screenshots/'Track A.png' -crop 280x70+110+90 /Users/test/Desktop/'Tynon Auto'/Screenshots/'Track XT9.png'
MORE CONVERT COMMANDs FOLLOW THIS

This is using ImageMagick to crop an image

can anyone help

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

with versions <1.1.0 you have to use os.popen() or the features of the subprocess module.

with version 1.1.0, you can do this:

result = run("env")

getting result as a multi line string like this:
0
SHELL=/bin/bash
LC_CTYPE=UTF-8
DYLD_LIBRARY_PATH=/Applications/NetBeans/NetBeans 7.4.app/Contents/Resources/NetBeans/webcommon/bin:
TMPDIR=/var/folders/72/r0r_pc952b97blkfdk5yh0hr0000gn/T/
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
SHLVL=1
…. more

the first line is the return code, the rest is the stuff going to stdout and lines after a line *****error***** the stuff that goes to stderr.

to run a script file created from scratch, just create a file wherever you want with the shebang in the first line and then the lines you need to be processed.

then issue
result = run("<the-path-to-your-commandfile> option1 option2")

--- crop an image
… also can be done with version 1.1.0 (not documented yet ;-)

img = Image.create("someFile.png")
imgCropped = img.getSub(x, y, w, h) # still in memory
imgCroppedFile = imgCropped.asFile() # a file in temp

… and this is possible:
find(imgCropped) # just use the in memory image

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#2

> to run a script file created from scratch, just create a file wherever
> you want with the shebang in the first line and then the lines you need
> to be processed.

Sorry what do you mean by shebang in the first line
and
Dont think I will need it for Cropping then - not in a rush so I can wait for 1.1.0 to be released - think I saw it was planned for August sometime.
but usefull to understand how to use the run() command

LOL :-
Google :-
shebang
ʃɪˈbaŋ/
noun
1.
informal
a matter, operation, or set of circumstances.
"the Mafia boss who's running the whole shebang"
2.
NORTH AMERICANarchaic
a rough hut or shelter.

> On 22 Jun 2015, at 14:26:28, RaiMan <email address hidden> wrote:
>
> Your question #268418 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/268418
>
> Status: Open => Answered
>
> RaiMan proposed the following answer:
> with versions <1.1.0 you have to use os.popen() or the features of the
> subprocess module.
>
> with version 1.1.0, you can do this:
>
> result = run("env")
>
> getting result as a multi line string like this:
> 0
> SHELL=/bin/bash
> LC_CTYPE=UTF-8
> DYLD_LIBRARY_PATH=/Applications/NetBeans/NetBeans 7.4.app/Contents/Resources/NetBeans/webcommon/bin:
> TMPDIR=/var/folders/72/r0r_pc952b97blkfdk5yh0hr0000gn/T/
> JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
> SHLVL=1
> …. more
>
> the first line is the return code, the rest is the stuff going to stdout
> and lines after a line *****error***** the stuff that goes to stderr.
>
> to run a script file created from scratch, just create a file wherever
> you want with the shebang in the first line and then the lines you need
> to be processed.
>
> then issue
> result = run("<the-path-to-your-commandfile> option1 option2")
>
> --- crop an image
> … also can be done with version 1.1.0 (not documented yet ;-)
>
> img = Image.create("someFile.png")
> imgCropped = img.getSub(x, y, w, h) # still in memory
> imgCroppedFile = imgCropped.asFile() # a file in temp
>
> … and this is possible:
> find(imgCropped) # just use the in memory image
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/268418/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/268418
>
> You received this question notification because you asked the question.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

If you just search for shebang with Google, as a top entry you should get:
https://en.wikipedia.org/wiki/Shebang_(Unix)

hope it helps.

No need to wait for the final:
http://sikulix.com

Can you help with this problem?

Provide an answer of your own, or ask Jeff_Vallis for more information if necessary.

To post a message you must log in.