WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] script not running  (Read 3906 times)

Offline SwagmanXX

  • Newbie
  • *
  • Posts: 4
[SOLVED] script not running
« 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
« Last Edit: February 15, 2013, 10:52:52 AM by SwagmanXX »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11587
Re: script not running
« Reply #1 on: February 15, 2013, 09:47:40 AM »
Hi SwagmanXX
Try removing the:
Quote
#!/bin/sh
from the file.

Offline SwagmanXX

  • Newbie
  • *
  • Posts: 4
Re: script not running
« Reply #2 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.

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: script not running
« Reply #3 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.
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline SwagmanXX

  • Newbie
  • *
  • Posts: 4
Re: script not running
« Reply #4 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.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: script not running
« Reply #5 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>
) &

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Re: script not running
« Reply #6 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.

Offline SwagmanXX

  • Newbie
  • *
  • Posts: 4
Re: script not running
« Reply #7 on: February 15, 2013, 10:51:56 AM »
@ gerlad_clark:
Your script works fine. Thanks for your help.


Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: script not running
« Reply #8 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.
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11587
Re: [SOLVED] script not running
« Reply #9 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.

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: [SOLVED] script not running
« Reply #10 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.  :)
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: script not running
« Reply #11 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.
« Last Edit: February 15, 2013, 02:10:10 PM by tinypoodle »
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: [SOLVED] script not running
« Reply #12 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)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: [SOLVED] script not running
« Reply #13 on: February 15, 2013, 03:01:40 PM »
That is what I meant by "interpreter directive".
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

aus9

  • Guest
Re: [SOLVED] script not running
« Reply #14 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