Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: SwagmanXX on February 15, 2013, 08:51:28 AM

Title: [SOLVED] script not running
Post by: SwagmanXX on February 15, 2013, 08:51:28 AM
Hi,

I'm trying to run a startup-script for the app rdesktop and having problems. I searched the forum and faq and followed the steps as described:

1.  tested rdesktop to my server --> entered following command in terminal console:
rdesktop -u <myusername> -d <mydomain> -p <mypassword> -k de -g 100% <serveripaddress>
--> rdesktop runs ok!

2. created a script file named rdes in folder "/home/tc/.X.d/" with following content:

#!/bin/sh
rdesktop -u <myusername> -d <mydomain> -p <mypassword> -k de -g 100% <serveripaddress>

3. made file rdes executable with entering command in terminal "~/.X.d/":
chmod 755 rdes
4. tested script file rdes in terminal "~/.X.d/":
sh rdes
-->script was executed and rdesktop was started.

So far so good. My problem is that my script rdes is not executed onboot. Means, when I turn on my computer TCL is booted but nothing else happens.

Thanks for any help & recommends.

Peter
Title: Re: script not running
Post by: Rich on February 15, 2013, 09:47:40 AM
Hi SwagmanXX
Try removing the:
Quote
#!/bin/sh
from the file.
Title: Re: script not running
Post by: SwagmanXX on February 15, 2013, 09:52:56 AM
Hi Rich,

removed first line in my script file. Unfortunately that didn't help.

When I start the script file in the terminal console with "sh rdes" it works fine.
Title: Re: script not running
Post by: Lee on February 15, 2013, 10:06:30 AM
Try adding some relevant logging to your script to ensure that it runs and what's going on when it does.
Could it be that it is running before the network is up?
If it doesn't run, maybe put that shebang back in if removing it didn't help.
Title: Re: script not running
Post by: SwagmanXX on February 15, 2013, 10:21:24 AM
Hi Lee,

Quote
Try adding some relevant logging to your script to ensure that it runs and what's going on when it does.
All I've set up by now is a result of searching the web and the threads of this forum. Unfortunately I've got no idea of writing scripts in linux an only know the basic console commands. Could you kindly give me a hint how to add logging to my script.

Quote
Could it be that it is running before the network is up?
How can I check that?

Quote
If it doesn't run, maybe put that shebang back in if removing it didn't help.
shebang is back in.
Title: Re: script not running
Post by: gerald_clark on February 15, 2013, 10:37:26 AM
(
until ifconfig | grep -q "Bcast" ;  do sleep 1 ; done
rdesktop -u <myusername> -d <mydomain> -p <mypassword> -k de -g 100% <serveripaddress>
) &
Title: Re: script not running
Post by: SamK on February 15, 2013, 10:46:20 AM
My understanding is that a scriptsin .X.d does not require to be made execuatble and adding #!/bin/sh is also not needed.

When .X.d/ is used here, it holds a single file which I name bootxapps.  Permissions are rw-r--r--, and ownership is tc:staff (or whatever username is).  All apps are started from this single file.  Commands are added as if the have been issued at the command line and run in the background if required.
Title: Re: script not running
Post by: SwagmanXX on February 15, 2013, 10:51:56 AM
@ gerlad_clark:
Your script works fine. Thanks for your help.

Title: Re: script not running
Post by: Lee on February 15, 2013, 10:59:26 AM
Regarding logging - I was just thinking of something like

Code: [Select]
#!/bin/sh
echo "`date` - about to run rdesktop" >>/tmp/rdesktoplog.txt
ifconfig >>/tmp/rdesktoplog.txt

rdesktop -u <myusername> -d <mydomain> -p <mypassword> -k de -g 100% <serveripaddress>

echo "`date` - done." >>/tmp/rdesktoplog.txt

gerlad_clark's code for running it in the background with a delaying loop would actually solve the problem rather than just detecting it, if that is the problem.

I don't know if scripts in .X.d are sourced (don't need shebang) or called (do need shebang) but either way, the shebang is technically a comment so it doesn't hurt.  The only time I omit it from a script is when I explicitly -don't- want it "called" - Usually when the script is an initialization file that sets variables to be used by the process that sources it.
Title: Re: [SOLVED] script not running
Post by: Rich on February 15, 2013, 11:14:09 AM
Hi Lee
From .xsession:
Code: [Select]
[ -d ".X.d" ] && find ".X.d" -type f -print | while read F; do . "$F"; doneI think the period between  do  and  "$F"  means it is sourced.

On a side note regarding the previous two posts, it's spelled  gerald_clark, not  gerlad_clark. Use the copy and paste
functions if necessary.
Title: Re: [SOLVED] script not running
Post by: Lee on February 15, 2013, 12:55:27 PM
Quote
I think the period between  do  and  "$F"  means it is sourced.

It does indeed.

Quote
it's spelled  gerald_clark, not  gerlad_clark.

Oops that was me that started that.  Sorry gerla gerald_clark.  :)
Title: Re: script not running
Post by: tinypoodle on February 15, 2013, 02:07:25 PM
the shebang is technically a comment so it doesn't hurt.
IMHO at least when disassociated from very specific context that would be an overgeneralized statement, a shebang is an interpreter directive of functional essence - and accuracy of every detail which follows it is crucial.
Title: Re: [SOLVED] script not running
Post by: gerald_clark on February 15, 2013, 02:45:03 PM
Shebang is actually used by the program loader to direct it to load the specified binary and hand the file as an argument.

http://en.wikipedia.org/wiki/Shebang_(Unix)
Title: Re: [SOLVED] script not running
Post by: tinypoodle on February 15, 2013, 03:01:40 PM
That is what I meant by "interpreter directive".
Title: Re: [SOLVED] script not running
Post by: aus9 on February 15, 2013, 07:09:09 PM
offtopic

weird, that link has not got the last bracket as a part of url

http://en.wikipedia.org/wiki/Shebang_(Unix)

but I learn something everyday....the whole shebang