Shell Scripts And File Visibility


p0is0n

Still Fresh
Joined
Aug 29, 2007
Messages
24
Age
38
Location
UK
Website
Visit site
Hi guys,

What i want to do is start my game using a shell script, and to have it so that all files/folders apart from the shell script are hidden.

From searching the forum i know that:
./the_executable
cd /usr/gp2x
exec ./gp2xmenu
would restart the menu app after the game exits.

What i need to know is:
How do i make a shell script file (i guess it can be made in notepad, but what file extension)?
How would i kill the gp2x menu.

I've never used shell scripts before so am a bit lost.

Also how do i make it so that files/folders cannot be seen?

Thanks in advance
 
No, you can't use notepad, you need a text editor that can save in Linux format (the new line characters are different)

http://www.freeos.com/guides/lsst/

has lots of shell scripting stuff

Programmers Notepad can save in Linux format

the extension can be anything, but .gpe or .gpu are normally used.

Not sure if this applies to the gp2x, but normally any files beginning with a . (period) are meant to be hidden.

exec ./gp2xmenu kills the menu and loads your app.


p0is0n said:
Hi guys,

What i want to do is start my game using a shell script, and to have it so that all files/folders apart from the shell script are hidden.

From searching the forum i know that:
./the_executable
cd /usr/gp2x
exec ./gp2xmenu
would restart the menu app after the game exits.

What i need to know is:
How do i make a shell script file (i guess it can be made in notepad, but what file extension)?
How would i kill the gp2x menu.

I've never used shell scripts before so am a bit lost.

Also how do i make it so that files/folders cannot be seen?

Thanks in advance
 
Last edited by a moderator:
Pre firmware 3.0.0 files with .gpu are shown in the utilities menu and .gpe in the games menu.

Firmware 3.0.0 (and F200?) there is no utils menu but .gpu and .gpe both show up in games.

Hiding files with '.' isn't supported, the best you can do is put all the files in a single subdirectory, then you only see that and the script.

You don't have to kill the menu, when your script runs it replaces the menu - that's why you have to start the menu at the end.

I suggest the following file structure:

CODE

MyGame/ -- Main directory
MyGame.gpe -- Launch script
MyGame.png -- Icon for game
mygamedata/ -- directory with game and data



In the script add

cd mygamedata

before ./the_executable
 
Thanks a lot guys, i'll try this later today.

Edit : Got my script working perfectly, thanks.
now all i need to do is to find a way of hiding the folders :D
 
honestly, every gp2x user must know how to navigate folders etc to use their unit anyway, i don't see a point trying to hide the folders... as long as its not confusing where to find the main executable (i.e. in Parkydr's structure it's obvious).

And if the user wants things tidier, they can install a proper menu ;)
 
I understand that you dont need to hide the folders, it would just look a tiny bit nicer if you couldnt see them.

I actually have 2 quick questions:
How do you assign a game icon with the script?
Is there any website that teaches you how to use the shell script that the gp2x uses?
(bearing in mind that i only need to be able to do simple things)

Also in my script when i do:
cd gamedata
./the executable
do i need to add the file extension for the executable?

Thanks
 
don't need to specify the icon yourself, the standard menu as well as gmenu (and probably gp2xmb but i can't check right now) automatically look for a file with the same name as the executable, but ending in .png.

as far as cleanliness...generally you hide files & folders in linux by prepending them with a dot. windows you do it with in file properties, dunno about mac. like others i'm gonna have to say that it's totally unncessary. but if you are really worried about it, you could use a cramfs file to store everything. alternatively you could compile your binary data into the program. but both things make continued work on the program more complicated on your end though, and for not a very good reason.
 
Thanks a lot rokdcasbah!

I thought that was the way to have your own icon, mine didnt work for some reason, but after trying again with a different name it works perfectly :)

As for hiding the folders i think you're right, too much hassle for something that isnt important.

Thanks again!!!
 
Hey guys,

Ok i have been trying to follow this about shell scripting. I thought i had it right but when i run it on the GP2X i just get a blank screen. any ideas as to why?

Thanks
 
Ok got a question.

How come this code
CODE

cd game
./Game.game
cd /usr/gp2x
exec ./gpexmenu



with the save name of launch.gpe only displays a blank screen and not my game?

I know my game works as when i launch the ./Game.game file my game runs.
 
Asherz said:
Ok got a question.

How come this code
CODE

cd game
./Game.game
cd /usr/gp2x
exec ./gpexmenu
with the save name of launch.gpe only displays a blank screen and not my game?

I know my game works as when i launch the ./Game.game file my game runs.



i don't think "cd game" will find the right directory, you'll probably need:

"cd /mnt/sd/game"

so it knows to look on the sd card
 
Last edited by a moderator:
Asherz. just the same you have to specify the path

you SD card is in /mnt/sd

therefore a directory in your SD card would be in /mnt/sd/HERE

if you tell the fil to CD game, it will look in /game and it will not work

given you asked what extension to use, it seems you are from a windows background =) (extensions in linux and windows are not the same at all).

To sum up what have been said so far:

- Make sure you use wordpad.exe and NOT notepad.exe to edit your files.
- Make sure you specify the whole path:
cd /mnt/sd/gamedir
./gamefile
sync
cd /usr/gp2x
exec ./gp2xmenu

EDIT: just in case you don't know, linux, contrary to windows, has a case sensitive file system... so if the directory is 'Game', using 'game' (lower case g) will not work.
 
I am a windows programmer.

I have tried with the cd /mnt/sd in front of /gamedir

but it still don't work.

So what would be the best file extension to use as im sure .rtf wouldn't work as that is a rich txt format which is what wordpad.exe saves out as as default.

What is the sync you added in there?

xcen said:
cd /mnt/sd/gamedir
./gamefile
sync
cd /usr/gp2x
exec ./gp2xmenu
 
Last edited by a moderator:
.gpe is what you need

sync is to sync the SD card (save changes) before returning to the menu...

errr did we mention to put

#!/bin/sh

at the begining of the file

I am not 100% sur you absolutely needed, but that's what they call the shebang (#!) it tells linux to run the file with /bin/sh, this way you can turn any linux file into an executable (that's if I understand properly)

give that a try
 
Ok so your saying making something like
CODE

#!/bin/sh
cd /mnt/sd/gamedir
./game
sync
cd /usr/gp2x
exec ./gp2xmenu


should work?

and calling the file launch.gpe from Windows wordpad.exe would be ok?
 
Back
Top