We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Execute shell script xubuntu
Page Index Toggle Pages: 1
Execute shell script xubuntu (Read 3380 times)
Execute shell script xubuntu
May 21st, 2009, 5:15pm
 
Hi,
I was wondering if anyone had a solution for launching shell scripts from processing.
I'm trying open() but it doesnt seem to be working,
the shell script like this:
#
clear
echo "Printing"
lpr test.txt

in processing I do:
void mousePressed(){
open("./print");
}

but this does not seems to be working for me. Am I doing something wrong?
Thanks

Re: Execute shell script xubuntu
Reply #1 - May 22nd, 2009, 10:21am
 
Quoting from the open() reference page:
Quote:
The location parameter must be a full path name, or the name of an executable in the system's PATH.

You have no guarantee on the current working dir...
Re: Execute shell script xubuntu
Reply #2 - May 24th, 2009, 5:38pm
 
Hi,
thanks for the heads up!!
so I tried also what you are saying and actually it's launching the script!! but the problem is my sketch is opening it in a text editor instead of running it.
My script file is in chmod u+x and I also edited propeties of the file to be launched as an application.
This is way easier on osx with apple script...
Re: Execute shell script xubuntu
Reply #3 - May 25th, 2009, 4:10am
 
jamsaver wrote on May 21st, 2009, 5:15pm:
the shell script like this:
#
clear
echo "Printing"
lpr test.txt


does it need the usual shebang on the first line

#!/bin/bash

to tell it which interpreter to use
Re: Execute shell script xubuntu
Reply #4 - May 25th, 2009, 7:00am
 
hi,
After the first post I added  #!/bin/bash it didn't change anything.
I'm thinking that this is a operating system problem...
I saw this on processing reference open()
"
On Linux, it first tries gnome-open, then kde-open, but if neither are available, it sends the command to the shell without any alterations.
"
I also tried doing something like this
void mousePressed(){
String[] params = {"lpr","test.txt"};
exec(params);
}
opens up a fresh terminal window but it doesnt run the command...

what am I missing here??
Re: Execute shell script xubuntu
Reply #5 - May 25th, 2009, 2:56pm
 
do you have gnome-open or kde-open?

i do (gnome-open) and it's displaying my script as text despite it being executable and having a .sh extension (oddly, .exe causes a different error)

even "gnome-open list.sh" opens it as text.

ok, i used nautilus to set that file to open using bash (right click, properties, Open With. add /bin/bash if necessary. associate the file (and possibly all .sh files) with this) and that's working now. gnome-open uses the nautilus mime-type settings. it's perhaps the wrong thing to use for bash scripts.
Re: Execute shell script xubuntu
Reply #6 - May 29th, 2009, 2:09am
 
Hello koogy I tried what you said, now the double click seems to be working but I can't get it to work from processing. Could you be kind enough to test to launch a .sh file from your processing app??

Thanks...
Re: Execute shell script xubuntu
Reply #7 - May 29th, 2009, 6:50am
 
i did test it like that and it worked, after i'd set it up using nautilus as specified

try
gnome-open file.sh
from the command line, get that working first
Page Index Toggle Pages: 1