Script & Stuff


Quiest

I like turtles!
Joined
Sep 2, 2004
Messages
3,411
Age
41
Location
Dteuschland ;)
I just looked at a gpe script and noticed that the menu is just run with

cd /usr/gp2x
./gp2xmenu

Are there any other thing that can be run by scripts we don`t know of yet or we can`t run by the menu?
 
I just tried it - now our neighbors house is gone (I threw the gp2x there after I heard it started ticking).
 
You could always run a script which saves a directory listing of /usr/gp2x to a txt file on the SD card and have a look. It wouldn't suprise me if there are a few hidden things in there. If I had my unit yet I'd have a look. :p

edit: I think this should work (note the 'should').

Code:
ls -a /usr/gp2x > /mnt/sd/gp2xlist.txt
 
You could always run a script which saves a directory listing of /usr/gp2x to a txt file on the SD card and have a look. It wouldn't suprise me if there are a few hidden things in there. If I had my unit yet I'd have a look. :p

edit: I think this should work (note the 'should').

Code:
ls -a /usr/gp2x > /mnt/sd/gp2xlist.txt

Better yet:

Code:
ls -alR /usr/gp2x > /mnt/sd/gp2xlist.txt

This will recursively list all files, and save you the trouble of going through each directory manually (plus it'll show which files are executable).

Come to think of it, that's the first thing I'm going to do when I get home :).
 
Last edited by a moderator:
To run commands like 'ls -alR /usr/gp2x > /mnt/sd/gp2xlist.txt',
you can write script like this.

#/bin/sh
mount /mnt/sd -o remount,sync
ls -alR /usr/gp2x > /mnt/sd/gp2xlist.txt
mount /mnt/sd -o remount,async
cd /usr/gp2x/
./gp2xmenu

save texts in .gpe file and run in game menu.

(windows notepad handles newlines differently. try using unix-compatible editor like editplus.)

and for example, you can use scirpt as a link.

#/bin/sh
mount /mnt/sd -o remount,sync
cd /mnt/sd/snes/
./snesgp2x.gpe
mount /mnt/sd -o remount,async
cd /usr/gp2x/
./gp2xmenu

save in snes.gpe and copy to root.
and now you have a link to /snes/snesgp2x.gpe in root folder. ;)
 
Haven't got mine yet but can you guys explain howto run linux commands on the gp2x??

You write a script, name it with a suffix of .gpu and put the following in there:

#/bin/sh

YOUR
COMMANDS
HERE

cd /usr/gp2x
./gp2xmenu

You make that script executable, put it on your SD card, and in the Utilities menu you select that script.

It's not very entertaining though, as you can not interact with the scell script and you you can not easily display output. You would have to direct your output to a file on the SD card. The script mentioned farther up in this thread, enriched by a command to copy the directory with all the GamePark stuff in it would look like this:

#/bin/sh
ls -R /usr/gp2x/ > /mnt/sd/all_the_files.txt
cp -r /usr/gp2x/* /mnt/sd/
cd /usr/gp2x
./gp2xmenu

There doesn't seem to be a whole lot of logging going on (would have surprised me) although the files like /var/log/messages exist. For your enjoyment I post the contents of /bin /sbin and /usr/bin

/bin:
addgroup
adduser
bash
busybox
cat
chgrp
chmod
chown
cp
date
dd
delgroup
deluser
devfsd
df
dmesg
dnsdomainname
doexec
domainname
echo
egrep
factor
false
fdisk
fgrep
ftp
gpm
grep
groups
gunzip
gzip
hostname
ipcalc
kill
ln
logger
login
ls
mkdir
mknod
more
mount
mv
netstat
nice
nisdomainname
nohup
pathchk
pidof
ping
pinky
printenv
printf
ps
pwd
rm
rmdir
sed
seq
sfdisk
sh
sleep
smtpclient
stty
su
sync
syslog
tar
tinylogin
touch
true
umount
uname
users
usleep
vi
who
ypdomainname
zcat

/sbin:
agetty
arp
autologin
cardctl
cardmgr
consoletype
depmod
dump_cis
e2fsck
e2label
expand
freeramdisk
fsck
fsck.ext2
fsck.ext3
fsck.minix
ftl_check
ftl_format
getkey
getty
halt
htpasswd
hwclock
ide_info
ifconfig
ifdown
ifport
ifup
ifuser
in.ftpd
in.telnetd
inetd
init
initlog
insmod
killall5
klogd
ksyms
login
losetup
lsmod
makeweb
mingetty
minilogd
mke2fs
mkfs
mkfs.bfs
mkfs.ext2
mkfs.ext3
mkfs.minix
mklost+found
mkswap
mkusers
modinfo
modprobe
nameif
netreport
pack_cis
passwd
pcinitrd
plipconfig
portmap
poweroff
probe
rarp
reboot
rmmod
route
rungetty
runlevel
shutdown
slattach
sulogin
swapoff
swapon
syslogd
syslogtocern
tcpd
telinit
thttpd
tune2fs

/usr/bin:
basename
cam2jpeg
cam2mp4
cam2video
chvt
clear
cut
dirname
du
env
expr
find
free
head
hostid
id
jpegdec
killall
last
lastb
logger
logname
mesg
nslookup
passwd
printf
reset
select-recording-source
simple-audio-player
simple-audio-recorder
sort
tail
tee
time
traceroute
tty
tv2video
uniq
uptime
utmpdump
wall
wc
which
whoami
xargs
yes


If there were an mkfs.vfat in there I would write a utility to format SD cards, but it's not in there... :(
 
Last edited by a moderator:
Times like these I wish I had a (wireless)network connection to the Gp2X, then you could telnet/ssh into and mess about with everything until it breaks! I expect you could do it with the serial cable but none of the computers I use have serial ports :angry:
 
has anyone been able to use the script to get the mplayer files so that those with messed up firmware installs can fix it?
 
uh.. eh.. that's what I said! You just read my post wrong. :p

Nuh-uh, I added the -l and -R switches :p.

#/bin/sh
mount /mnt/sd -o remount,sync
ls -alR /usr/gp2x > /mnt/sd/gp2xlist.txt
mount /mnt/sd -o remount,async
cd /usr/gp2x/
./gp2xmenu

Yeah, why is that?

AFAIK: #/bin/sh is not a full shebang line, so shouldn't work. But it does. Also, I've seen files without the shebang line which seem to work.

And why the remount? I know the Quake launch script does it, but the SDL install script doesn't, and it works fine as well. What purpose does the remount serve?
 
Last edited by a moderator:
Scripts can work without #!/bin/sh because whatever shell is running at the time will just execute the commands instead of sh, and the reason #/bin/sh works is because without the ! it's just a comment and so doesn't do anything.

The remount stuff I used for quake is because I was trying to figure out a way of getting data to actually save to the card. Normally with flash cards under linux the data isn't actually written to the card until it is unmounted, but with the gp2x you usually just save your game then switch off and so umount is never called and the data is never written. I was playing around with a few different ways of getting the data onto the card, but my prefered way (running sync after calling the save function) didn't seem to work as well as I thought it should (or I wasn't doing something right). As I was in a rush to get Quake released I settled on using that script to set the sd to sync mode before Quake starts, then set it back to async when it finishes (mounting as sync causes the data to be written immediately - slower, but seems to work). So, unless you're running an app that needs to get data written to the sd, mounting as sync in your script is just a silly thing to do ;). Picking bits out of other peoples code is always the best way to learn new stuff, but it pays to actually learn from it and not just copy randomly ;).
 
Times like these I wish I had a (wireless)network connection to the Gp2X, then you could telnet/ssh into and mess about with everything until it breaks! I expect you could do it with the serial cable but none of the computers I use have serial ports :angry:

USB to serial adapters are <$15 shipped on ebay. If you are able to telnet in with one of these, please post the results!
 
Last edited by a moderator:
Scripts can work without #!/bin/sh because whatever shell is running at the time will just execute the commands instead of sh, and the reason #/bin/sh works is because without the ! it's just a comment and so doesn't do anything.
I figured as much. Thanks for the confirmation.

Normally with flash cards under linux the data isn't actually written to the card until it is unmounted, but with the gp2x you usually just save your game then switch off and so umount is never called and the data is never written.

Of course, I should have guessed. But I wonder if it wouldn't be best to disable write caching altogether. After all, this device is supposed to be a console, so it should behave like one. Meaning just powering it off at any point shouldn't have unexpected consequences (such as caches not being flushed and files that were available previously suddenly being gone or corrupted). In conclusion: shouldn't the SD be mounted as `sync' all the time?

Afaik, this should only affect write operations, not read operations, so shouldn't have much influence on the working speed of the device, but it would increase reliability. Or are there some consequences I don't know about, such as disabling write caching also disables read caching?
 
Last edited by a moderator:
What happens if you run something and it doens't call gp2xmenu after it finishes? Do you just get a black screen and have to reset your unit? If so, it'd be handy for people to in future release launch scripts (some games have come with them, others not) which does all this for users to make it easier. When it's released in Jan '06, a lot of non-linux people will want to get them and the more user friendly it is, the bigger the community will get. :)
 
Back
Top