You are not logged in.

#1 2011-05-30 02:25:48

Dethredic
Member
Registered: 2009-01-24
Posts: 361
Website

Bash script won't echo parameters

I have an arduino and I want to modify the launching script so that it will allow me to open sketches with "arduino test.pde" instead of a blank sketch. If you don't know what I am talking about don't worry, you don't need to know about an arduino

Here is the script:

#!/bin/sh
echo "$1"

APPDIR="$(dirname -- $(readlink -f -- "${0}") )"

cd $APPDIR

for LIB in \
    java/lib/rt.jar \
    java/lib/tools.jar \
    lib/*.jar \
    ;
do
    CLASSPATH="${CLASSPATH}:${LIB}"
done
export CLASSPATH

LD_LIBRARY_PATH=`pwd`/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export LD_LIBRARY_PATH

export PATH="${APPDIR}/java/bin:${PATH}"

java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base $1

If I replace the $1 in the last line with something like /home/phil/test.pde then it opens up fine and does what I want (but only works for 1 file).
Unfortunately the script is not accepting the parameter correctly for some reason. The echo "$1" in the second line does not echo anything back thus the last line doesn't open the script.

For example if I type "arduino lol" a blank line is echoed back.

Offline

#2 2011-05-30 06:23:28

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: Bash script won't echo parameters

~ $ cat /tmp/test 
#!/bin/sh
echo "$1"
~ $ /tmp/test test
test

You must be doing something different....

Is there another `arduino` in your PATH?

Last edited by fukawi2 (2011-05-30 06:24:20)

Offline

#3 2011-05-30 11:12:21

Dethredic
Member
Registered: 2009-01-24
Posts: 361
Website

Re: Bash script won't echo parameters

nope. the "arduino" in /usr/bin points to the script I pasted in post 1 which is located in /usr/share/ardiuno/arduino

I am confused because I previously did something similar to you and it didn't work

Offline

#4 2011-05-30 11:31:14

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: Bash script won't echo parameters

Dethredic wrote:

nope. the "arduino" in /usr/bin points to the script I pasted in post 1 which is located in /usr/share/ardiuno/arduino

Have you confirmed that that is what is being executed though?

which arduino

Edit: or tried running it with the full path?

Last edited by fukawi2 (2011-05-30 11:31:58)

Offline

#5 2011-05-30 14:01:24

Dethredic
Member
Registered: 2009-01-24
Posts: 361
Website

Re: Bash script won't echo parameters

fukawi2 wrote:
Dethredic wrote:

nope. the "arduino" in /usr/bin points to the script I pasted in post 1 which is located in /usr/share/ardiuno/arduino

Have you confirmed that that is what is being executed though?

which arduino

Edit: or tried running it with the full path?

I have confirmed that the script is being executed because when I edited the last line of the script to:
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base /home/phil/test/test.pde
it opens the correct file.

That being said I just thought of something. The parameter that I am passing is going to /usr/bin/arduino, and that could not be passing it along to /usr/share/arduino/arduino

I am at work so I can't test this, but it seems logical. Will report back tonight. Thanks for the ideas.

Offline

#6 2011-05-30 22:37:52

Dethredic
Member
Registered: 2009-01-24
Posts: 361
Website

Re: Bash script won't echo parameters

That indeed fixed it. Thanks for the input.

Offline

Board footer

Powered by FluxBB