Posts: 1,097 | Thanked: 650 times | Joined on Nov 2007
#51
Did you remember to grant execute permission while as root to the script ?

so essentially
> sudo gainroot
> cd < to directory where script is stored>
> ls -l - to check the presence of the pan_start.sh file in the listed files
> chmod a+x pan_start.sh - provided that is the name of the script file
> ./pan_start.sh

that should get the script running
 
Posts: 1,097 | Thanked: 650 times | Joined on Nov 2007
#52
Originally Posted by fanoush View Post
if the script in post #42 fails in mysterious ways then check long lines, some parts splitted to multiple lines in quoting above must be single long line to work correctly, see
http://www.internettablettalk.com/fo...034#post104034
Yes, good point fanoush. I quoted the text file, hence it may be wrapped into 2 lines and have a line berak in between.

BTW, thanks to your base script - which got mine working also - with some tweaks.
 
Posts: 4,030 | Thanked: 1,633 times | Joined on Jul 2007 @ nd usa
#53
Originally Posted by juanzone View Post
Nilchak,

Why do I get permission denied when I run the script? I have installed becomeroot package and I am in root already. --->#. I have followed your instructions to the letter and I am just stuck at being unable to run the script. Thanks for any help.
"Permission denied" means a lot of thing, one of them is you typed something that is NOT supposed to be there. What did you type?


bun
 
Posts: 9 | Thanked: 0 times | Joined on Jan 2008
#54
Originally Posted by bunanson View Post
"Permission denied" means a lot of thing, one of them is you typed something that is NOT supposed to be there. What did you type?


bun
I typed:

./pan_start.sh

in the directory where I put the script in.

TIA
 
Posts: 9 | Thanked: 0 times | Joined on Jan 2008
#55
Originally Posted by nilchak View Post
Did you remember to grant execute permission while as root to the script ?

so essentially
> sudo gainroot
> cd < to directory where script is stored>
> ls -l - to check the presence of the pan_start.sh file in the listed files
> chmod a+x pan_start.sh - provided that is the name of the script file
> ./pan_start.sh

that should get the script running
I run the script under root. I then cd to /media/mmc1/
ls -l shows the file pan_start.sh is in the memory card
If I do chmod a+x pan_start.sh and then try to run the script, it then says:

/bin/sh: pan_start.sh: not found


If instead of chmod a+x pan_start.sh I use chmod +x pan_start.sh, then I end up with

/bin/sh: permission denied




Last edited by juanzone; 2008-02-09 at 21:58.
 
pycage's Avatar
Posts: 3,404 | Thanked: 4,474 times | Joined on Oct 2005 @ Germany
#56
You cannot execute programs from the memory cards. You can however do
Code:
sh /media/mmc1/pan_start.sh
or copy pan-start.sh to the root filesystem, e.g. into /home/user.
 

The Following User Says Thank You to pycage For This Useful Post:
Posts: 9 | Thanked: 0 times | Joined on Jan 2008
#57
Originally Posted by pycage View Post
You cannot execute programs from the memory cards. You can however do
Code:
sh /media/mmc1/pan_start.sh
or copy pan-start.sh to the root filesystem, e.g. into /home/user.
Thanks for the help. However,

If I try the 1st command:
sh/media/mmc1/pan_start.sh

what happens is the script runs but says:
/media/mmc1/pan_start.sh: line 105: syntax error: word unexpected (expecting "in")

I compared the scipt to the other scripts in this forum and line 105 is blank

If I try moving the script to /home/user and I 1st ls and the file is indeed there. I chmod a+x pan_start.sh and run the script, an error occurs and says pan_start.sh file not found.

Can you tell me what I'm doing wrong? Thanks.

 
pycage's Avatar
Posts: 3,404 | Thanked: 4,474 times | Joined on Oct 2005 @ Germany
#58
There must be some syntax error in the script then. I guess the easiest would be to post it here.

If you want to execute from the root filesystem, you need to give the path to the executable. If it's in the current directory, this would be:
Code:
./pan-start.sh
 
Posts: 9 | Thanked: 0 times | Joined on Jan 2008
#59
This is what I've been using and I've been using ./pan_start.sh to run the script after making it executable. Thanks.

Code:
#!/bin/sh
# use gainroot to become root and relaunch itself
if [ `id -u` != 0 ] ; then
echo 'root'
#if not already root, call itself as root
exec sudo gainroot <<EOF
exec $0 $*
EOF
exit $?
else
echo 'notroot'
fi
# real script follows

BTADDR='00:1e:7d:94:5e:ce' # replace with your BT Address of phone
BTNAME="WM_Ryan1" # user your Phone BT Name as assigned
#IP=192.168.2.2
#GW=192.168.2.1
NS=192.168.2.1
PAN_ROLE=NAP # remote PAN role, one of NAP, GN

infoprint(){
DBUS_SESSION_BUS_ADDRESS='unixath=/tmp/session_bus_socket' dbus-send --session --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint "string:$*" &
}

dbus_method(){
local dest=$1
shift
DBUS_REPLY=$(dbus-send 2>&1 --system --type=method_call --print-reply --dest="$dest" $* )
}

dbus_result(){
echo $DBUS_REPLY | cut -d ' ' -f 7 | tr -d \"
}

find_connection(){
#find or create connection
if dbus_method org.bluez /org/bluez org.bluez.Manager.ActivateService string:network ; then
NET_BUS=$(dbus_result)
# echo destination $NET_BUS
if dbus_method "${NET_BUS}" /org/bluez/network org.bluez.network.Manager.FindConnection string:"${BTADDR}" ; then
CONN=$(dbus_result)
else
if dbus_method "${NET_BUS}" /org/bluez/network org.bluez.network.Manager.CreateConnection string:"${BTADDR}" string:"$PAN_ROLE" ; then
CONN=$(dbus_result)
fi
fi
fi
}


bnep_start(){
#find_connection
if [ "$CONN" != "" ] ; then
echo connection $CONN
if dbus_method "${NET_BUS}" ${CONN} org.bluez.network.Connection.Connect ; then
BNEPDEV=$(dbus_result)
echo connected to $BNEPDEV
#ifconfig $BNEPDEV $IP up
#if route -n | grep -q '^0.0.0.0' ; then
# echo "default gateway already set, skipping GW and DNS setting"
#else
# route add default gw $GW
# echo "nameserver $NS" >/tmp/resolv.conf.lo
#fi
udhcpc -i $BNEPDEV
[ -t 1 ] || infoprint "Connected to $BTNAME"
fi
fi
}

bnep_stop(){
#find_connection
if [ "$CONN" != "" ] ; then
echo connection $CONN
if dbus_method "${NET_BUS}" ${CONN} org.bluez.network.Connection.Disconnect ; then
echo "OK, bringing down"
echo -n '' >/tmp/resolv.conf.lo
[ -t 1 ] || infoprint "$BTNAME disconnected"
fi
fi
}

echo "Searching for $BTADDR ..."
[ -t 1 ] || infoprint "Searching for $BTADDR"
find_connection
if [ "$CONN" = "" ] ; then
echo $DBUS_REPLY
echo "Setting up connection to $BTADDR failed"
[ -t 1 ] || infoprint "Connection to $BTADDR failed"
exit
fi

COMMAND=$1
if [ "$COMMAND" = "" ] ; then
dbus_method "${NET_BUS}" ${CONN} org.bluez.network.Connection.IsConnected
if [ "$(dbus_result)" = "true" ] ; then
COMMAND=stop
else
COMMAND=start
fi
echo $COMMAND
fi

case $COMMAND in
start) bnep_start ;;
stop) bnep_stop ;;
esac
 
Posts: 1 | Thanked: 0 times | Joined on Feb 2008
#60
to juanzone: you are getting this message, because you saved the script in windows format(line endings). If you open the script under Linux, you will see ^M at the end of each line. Just simply save it with unix line endings.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 14:38.