Samba Client


Lobo

Active Member
Joined
May 9, 2006
Messages
527
I'm trying to get my GP2X to connect to a windows share, but I want to do a script to automate the process a little. Note that if I input the exact same instructions while connected via Telnet it works perfectly, I just can't get the script right.


I've got this in a GPU but it doesn't seem to be working:


#!/bin/sh

$/sbin/insmod smbfs

$mkdir /mnt/ext
$smbmount //192.168.0.20/ISOs /mnt/ext -o password=MySuperPass

cd /mnt/sd/gmenu2x
exec ./gmenu2x


BTW, I manually turn on USB networking and SAMBA/Telnet etc in the settings menu prior to launching my script.
 
why the '$' ?

also, unless the /mnt is on something like tmpfs, then you only need to do it once.
 
I added the dollar sign because thats what I had to type via Telnet. It's different in a script?

I don't need to do the mount? I was under the impression that as soon as I turn off my GP2X I would lose the mapped shared folder, therefore I would need to do it each time I boot the Gp2X.


As you can see, I have absolutely no idea what I'm doing here :)



All I want is a script which I can call from gmenu to enable samba and connect me to a share on my windows box. Any takers?
 
You need to open a user called "root" in windows. It's better if you set a password for it. Make your shared directory accesible by this user.

Use the following command lines:

insmod smbfs
sleep 1
smbmount //192.168.0.1/winShare /mnt/ext -o username=root,password=111111

I use it like this and it works.
 
oops!No, I'm confused. I have no idea why I was adding a $ at the beginning!

Thanks to both of you: I removed the $, added the "username=" argument and that did the trick!


Don't suppose you guys know how to actiavte USB networking via scripting too? So I don't even have to go into the settings menu at all?
 
isn't that setting saved between reboots? It certainly is on mine - I've only ever set it once.
 
It has the possibility to be "always on" but I don't have that activated by default because I thought it might affect battery life. I guess I can leave it on for a few days while I do my testing.


Thanks for all the help lads!
 
"Always on" is the same as switching it on every time you switch the 2x on. I don't see it using up battery life more quickly as all it does is load a few modules. I'd say worse case is that it uses up some memory (and maybe some processor time, but that should only be when you plug a lead into it).
 
It does only use memory, the only disadvantage is you won't be able to use the GP2X as a mass storage device while it's on, but most people don't anyway.
 
Thanks for all the help lads: I've got it working the way I want now, only problem is I sometimes have to run the script/.gpu twice to get it to connect to the share properly, but apart from that it's doing exactly what I want.
 
Well, if your PC is being fussy, you can always drop a while loop in that script that attempts a mount, does a 'df' to check if it mounted, and if not, go around for a second go :)

'grep' returns exit status of 0 if lines are found, or 1 otherwise, so you could use that as your condition.

But if you don't mind doing it yourself, thats fair enough. I just don't see the point when the 2x can do it for you :)

For example, something like:

SMBCMD="<your samba command>"
MNTTXT="<some unique text in your mount dir such as your ip>"

$SMBCMD
df | grep -i "$MNTTXT"
while [ "$?" = "1" ]; do
sleep 1
$SMBCMD
df | grep -i "$MNTTXT"
done
 
I need to use this, but can't get any scripts to work.
All I get from starting the .gpu is a blank screen and it never returns to gp2xmenu or gmenu2x. I need to shut down the 2X.

Here's my script:
CODE
!#/bin/sh
/sbin/insmod smbfs
smbmount //192.168.0.1/c /mnt/ext/c -o guest
smbmount //192.168.0.1/movies /mnt/ext/movies -o guest
smbmount //192.168.0.1/music /mnt/ext/music -o guest
smbmount //192.168.0.1/gp2xhomebrew /mnt/ext/gp2xhomebrew -o guest


Black screen and what seems to be a frozen GP2X is all that I get.
This works FINE over telnet, but I want to automate the process so I don't need to walk up to my computer and log in to telnet every time I boot my GP2X up.

I use ubuntu with nano texteditor so unix format should not be an issue I guess, as it could have been with notepad in windows.

EDIT: I have verified that there is nothing wrong with the script, executing it from telnet works (/mnt/sd/samba_mount.gpu) and all shares show up fine.
But running it from the GP2Xmenu or GMenu2X just doesn't work. :blink:

EDIT: Thought I had it working there for a while, but nope. Still not mounting. I get back to the menu now though. But the smb-shares do not mount.
Executing the script from telnet as root works though, do I need to set permissions for the .gpu ?
 
Ok, it's really refusing me to do this..
Has anyone been able to do this at all? Mount smbshares upon boot that is.
I can do it fine manually over telnet or even running the actual script over telnet works like a charm, but I don't want to use telnet every time.

This is the current script:
CODE

/sbin/insmod smbfs && smbmount //192.168.0.1/anime /mnt/ext/anime -o guest
cd /mnt/sd/gmenu2x-0.9-test1
exec ./gmenu2x


This is a separate script and not in autorun.gpe, else the usb network probably wouldn't be up yet.
I have tried to chmod 777 smb.gpu && chown root smb.gpu && chgrp root smb.gpu, nothing seems to work.

I'm using firmware version 2.0.0 ( I was unable to get USB working on 2.1.1 )

EDIT: Ok, here is the log.
QUOTE

----
GMenu2X starting: If you read this message in the logs, check http://gmenu2x.sou
----
SDL_SYS_JoystickInit
Unrecognized option: gamma
Adding surface: skin:sections/applications.png
Adding surface: skin:sections/emulators.png
Adding surface: skin:sections/games.png
Adding surface: skin:sections/settings.png
Adding skin surface: imgs/bg.png
Adding skin surface: imgs/topbar.png
Adding skin surface: imgs/bottombar.png
Starting main()
Adding skin surface: imgs/selection.png
Adding skin surface: icons/section.png
Adding surface: icons/ebook.png
Adding surface: icons/explorer.png
Using /lib/modules/2.4.25/kernel/smbfs.o
108: session request to 192.168.0.1 failed (Called name not present)
108: session request to 192 failed (Called name not present)
108: tree connect failed: ERRDOS - ERRnoaccess (Access denied.)




Ok, getting somewhere? How come I get this ERRnoaccess Access denied error and what should I do in order to fix it? It ONLY happens when I run the script from gmenu2x or gp2xmenu, not from telnet.
 
Is smbmount in the path? Maybe putting the path in the script will help?

Also, maybe smbmount is asking for a password? In which, redirecting input from null may work?

Best way to add debugging is to run your script from another script, and add ">/mnt/sd/output.txt 2>&1" to the line that executes the script.
 
Yes, smbmount is in the path, else it wouldn't have outputted that error.
By putting "-o guest" smbmount does not ask for a password.
QUOTE
Using /lib/modules/2.4.25/kernel/smbfs.o
SMB connection failed
101: session request to 192.168.0.1 failed (Called name not present)
101: session request to 192 failed (Called name not present)
101: tree connect failed: ERRDOS - ERRnoaccess (Access denied.)
 
Back
Top