I Need Some Help With Scripts (again)


T

TelcoLou

Guest
* deep breath *

I was trying to make a launch script for Frodo & FrodoPC. I finally got it to work after nearly an hour of frustration using this:

Code:
#!/bin/sh

/mnt/sd/cpu_speed.gpe 1 2 266
cd /mnt/sd/
./FrodoPC.gpe
sync

cd /usr/gp2x/
exec /usr/gp2x/gp2xmenu

What I don't understand is this; I was trying to copy a script I made for GP2Xhandy:

Code:
#!/bin/sh

/mnt/sd/cpu_speed.gpe 1 2 266
/mnt/sd/GP2XHandy.gpe
sync

cd /usr/gp2x/
exec /usr/gp2x/gp2xmenu

... I simply replaced this line:

/mnt/sd/GP2XHandy.gpe

with this:

/mnt/sd/Frodo.gpe

... when I executed the script, I got dumped back to the GP2X menu. So I changed it thusly:

cd /mnt/sd/
./FrodoPC.gpe


My question is, "What the HELL is the difference??!??" I'm not real bright, but it seems that I'm telling the script to do the same thing; run the prgram located in the root.

I just don't get it :lol:
 
TelcoLou posted on Feb 24 2006 at 08:03 PM said:
/mnt/sd/Frodo.gpe

cd /mnt/sd/
./FrodoPC.gpe

The second form changes the current directory, the first does not. Some things need to be run from their own directory to work properly. I assume that's what's going on here.
 
Last edited by a moderator:
Keep at it TelcoLou :)

Generally speaking, it's best to cd into the directory that contains the executable and it's files first and then run it - instead of just trying to run it directly.
 
Thanks all :)

I just don't understand why my GP2Xhandy script works, yet using the same syntax, the Frodo script fails ...
 
It's not the same syntax.

One is running the path of the file without changing where it's running from. The other changes to that path and then runs. It's similar to when you right click on an icon in Windows, there's an option to run from another directory. That's what you're doing, and some programs need to be in that directory in order to be run, others may not be as forgiving depending on if they have a config file or something like that to check.
 
In the case of frodo - what you are calling is frodo.gpe - which is actually a shell script which in turn calls the executable frodo (note the name is just frodo).

frodo.gpe calls frodo like so

Code:
./Frodo
Now can you see the issue if I am in say the directory /home/TelcoLou and I say ./frodo when Frodo (the app) and it's files are located in / ?

GP2Xhandy works in your example because GP2Xhandy.gpe is in fact an executable and it has no other required files that it needs when it runs. So in this case, you can get away with not changing to the parent directory for GP2Xhandy first and still have it run properly.
 
:eek:

It makes sense now. Frodo.gpe & FrodoPC.gpe are scripts! <DOH!>

Thank you all for your patience ... :)
 
right, and even if it isn't a script, it might still need to be called in it's own directory. the safest thing to do is always cd before you execute...however it's ok to do the cpu tweaker on one line.
 
Back
Top