Can't run .sh script files

mrabcx

Member
Joined
Aug 13, 2007
Messages
6
Reaction score
0
Points
0
Age
48
My Satellite Setup
DM500S
My Location
Sweden
I have a problem running .sh scripts on my Dreambox 500, with
standard enigma image. What is do is what I find described
on many sites: copy the .cfg and .sh file to /var/tutbox/plugins,
set filemode to 755 and then I try to run the script with the
blue button panel. The script does show up in the menu
but when I click on it nothing happens. An empty window
comes up and that's it. The script is very simple for testing and there is no reason why it should not work.

I then tried the script plugin I found on
http://www.satellites.co.uk/satellite/dreambox-general/57373-script-plugin.html
but when I try to run script01.sh all I get is an error
message:
-sh: script01.sh: not found
even thogh the file is at the right place.
Strangely, if I try to directly run the file from the
shell by typing /var/bin/script01.sh etc. I end up with the same error
message even though the file is there and all modes
are set correctly.

What on earth am I doing wrong ?!?! Is there something wrong
with sh and how do I fix it ?

All help will be appreciated.
 

PJ02

Regular Member
Joined
Nov 29, 2006
Messages
150
Reaction score
0
Points
0
Age
44
My Satellite Setup
1.2m CM, 36v Positioner, DB7020Si.
Diablo, CAS3+
My Location
Cheshire
linux is case specific, so make sure it's exactly as you typed.

Also if you are in the folder where the .sh file is just run ./script01.sh

chmod +x or +e (can't remeber) is another option but i'm sure chmod 755 does the same.

Rgds

PJ
 

mrabcx

Member
Joined
Aug 13, 2007
Messages
6
Reaction score
0
Points
0
Age
48
My Satellite Setup
DM500S
My Location
Sweden
Thank you very much for your reply.

Well,
I have a file script01.sh in /var/bin directory.
The mode is +x.
I cd to /var/bin and try to run it:
./script01.sh
What do I get ?:
-sh: script01.sh: not found

The file is there, the modes are correct so there
must be something else which is wrong.
Something to with the fact that sh is not initialised properly ? Any idea ?
This is driving me crazy.
 

billnot

Growing Old Disgracefully
Joined
May 23, 2003
Messages
242
Reaction score
0
Points
0
Age
84
My Satellite Setup
Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
My Location
Benitachell, Alicante, Spain
I'm wondering, like PJ, if you have something wrong with case, etc.

Linux is case sensitive - script01.sh and Script01.sh, for example, are different files. Secondly, are you getting 0 (figure zero) and O (capital letter o) mixes up?.

You say the file is there. Could you run the following and paste (or put a link) to the resultant file:

cd /var/bin
ls -l > /output.txt

This will create a file, output.txt, in the root directory of your Dreambox, containing a list of the files in the /var/bin directory.

If I can examine it, it may help me.

Finally, as a long shot, try loading a fresh shell like this:

cd /var/bin
sh script01.sh

If that doesn't work, the file is definitely not where you think it is, or not named as you think it is.
 

mrabcx

Member
Joined
Aug 13, 2007
Messages
6
Reaction score
0
Points
0
Age
48
My Satellite Setup
DM500S
My Location
Sweden
No, the cases are right (I anyway often use the Tab key to
fill in).

Here is the output of out.txt:

-rwxr-xr-x 1 1000 100 630580 Jul 26 17:32 CCcam
-rwxr--r-- 1 root root 16990 Aug 15 16:50 CCcam.cfg
-rwxr-xr-x 1 root root 1226 Jul 29 22:45 camd_cfg
-rwxr-xr-x 1 1000 100 13972 Apr 16 19:23 capmtserver
-rwxr-xr-x 1 root root 4152 Jun 21 2006 enigmanet
-rwxr-xr-x 1 root root 5768 Jun 21 2006 gdaemon
-rwxr-xr-x 1 root root 27452 Jun 21 2006 inadyn
-rw-r--r-- 1 root root 0 Aug 17 22:33 out.txt
-rwxr-xr-x 1 root root 25 Aug 13 20:47 script01.sh
-rwxr-xr-x 1 root root 95 Jan 24 2006 smbmount.sh

I myself have tried to run the script from a 'fresh'
shell by: sh script01.sh
but that only gives an
even more complicated (corrupted ?) response back:

: not found: 2:
: not found: 3: ifconfig
: not found: 4:

(The file script01.sh btw just contains these 3 lines:)
#!/bin/sh

ifconfig

In this case the file does seem to be read and executed but sh
can't see to make any sense of it.
There is something wierd going on in my system, isn't it ?
But then apart from these scripts, everything else just works
perfectly fine ...
Could it be something wrong with Gemini 3.0 ?
 

billnot

Growing Old Disgracefully
Joined
May 23, 2003
Messages
242
Reaction score
0
Points
0
Age
84
My Satellite Setup
Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
My Location
Benitachell, Alicante, Spain
OK, now we're getting somewhere. script01.sh is running, but it can't find ifconfig. It's neither in the current directory nor in the path. That's what the "not found" message means - it's a message generated by the script, and I should have twigged earlier.

So there's nothing wrong with your scripting system. What you have to do is to locate ifconfig and edit the script accordingly.

My own Dreambox is a 7025, and ifconfig is in the
/usr/lib/ipkg/alternatives
directory. I don't know where it is on a 500 (but if you need, I can go through how to find out).

So for me the script would read:

#!/bin/sh
/usr/lib/ipkg/alternatives/ifconfig
 
Joined
Nov 21, 2006
Messages
8
Reaction score
0
Points
0
Age
86
My Satellite Setup
500-s
My Location
USA
mrabcx said:
I have a file script01.sh in /var/bin directory.
The mode is +x.
I cd to /var/bin and try to run it:
./script01.sh
What do I get ?:
-sh: script01.sh: not found

Some Possibilites:
1. script01.sh isn't in /var/bin ( seems it is )
2. ./script01.sh isn't being run from inside /var/bin ( try including the absolute path, i.e. run /var/bin/script01.sh )
3. script01.sh isn't executable ( prepend command w/ sh, i.e. sh /var/bin/script01.sh to check )
4. There's an error in the script ( i.e it doesn't begin with #!/bin/sh, etc. )

Good luck,
--
hemi

Ps. Oops, as the script ran w/ "sh script01.sh" seems it was #3. On a 500 /sbin/ifconfig should be linked to Busybox, but /sbin should also be in the default path already, so I dunno...
 

billnot

Growing Old Disgracefully
Joined
May 23, 2003
Messages
242
Reaction score
0
Points
0
Age
84
My Satellite Setup
Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
My Location
Benitachell, Alicante, Spain
I refer my honourable friend Hemi to the answer I gave above his.

The problem is that the script can't find ifconfig.
 
Joined
Nov 21, 2006
Messages
8
Reaction score
0
Points
0
Age
86
My Satellite Setup
500-s
My Location
USA
The original problem was the script wasn't executable "-sh: script01.sh: not found". I responded before thoroughly comprehending the thread, though. I somehow glanced over where you had already had him prepend the command w/ sh, identifying the original problem.

Sorry
--
hemi
 

billnot

Growing Old Disgracefully
Joined
May 23, 2003
Messages
242
Reaction score
0
Points
0
Age
84
My Satellite Setup
Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
My Location
Benitachell, Alicante, Spain
No, the problem has been all along that the "not found" message was generated by the script, which has always run correctly. It has always been ifconfig that script01.sh hasn't found. This has had everybody fooled, including me until I worked it out.

Don't you just love Linux error messages!
 

mrabcx

Member
Joined
Aug 13, 2007
Messages
6
Reaction score
0
Points
0
Age
48
My Satellite Setup
DM500S
My Location
Sweden
Well, regardless what the actual problem is, I'm still stuck!

ifconfig is in /sbin/ifconfig (linked to busybox), so
I changed ifconfig command in the script to
/sbin/ifconfig
but still no luck.
I still get:

: not found: 2:
: not found: 3: /sbin/ifconfig
: not found: 4:

The problem can not be with the fact that ifconfig is not found,
because when I run the script by forcing sh (sh script01.sh)
then I don't get one single line of error message but three,
where the empty lines also give the error message. Surely that
should not happen if the script could only not find the ifconfig.

My goal is of cousre not to rund this simple script with
'ifconfig' but more complicated ones and the one I originally started
with had some 'if else' structure at the startup. That gives
me the same error messages for that as well as.

And if try to run the script without typing sh then sh apparently
can't find the script. Why not ?!!
I guess there are initilizing problems somewhere, the paths don't
get set up correctly or something similar.
 

billnot

Growing Old Disgracefully
Joined
May 23, 2003
Messages
242
Reaction score
0
Points
0
Age
84
My Satellite Setup
Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
My Location
Benitachell, Alicante, Spain
Weird! Rather than push you deeper into the mire, I'll admit I'm clean out of ideas!
 

mrabcx

Member
Joined
Aug 13, 2007
Messages
6
Reaction score
0
Points
0
Age
48
My Satellite Setup
DM500S
My Location
Sweden
Ok, I got is sorted out. Just thought I would let know how.

In the /var/script folder I found a couple of other scripts and strangely they were executing correctly whenever I just typed in their filename. So what I basically did was to copy one of the files to where I wanted them (ie /var/bin), used vi replace the original content with my commands (such as ifconfig) and also renamed the file to script01.sh. Now the script works like a charm!

I have previously been using FileZilla to copy the script files from my PC to DB and maybe some file settings were set inncorrect by ftp ? Strange. I still don't understand what these settings could be. Anyway, my problem has not been sorted. Thanks for your help.
 

billnot

Growing Old Disgracefully
Joined
May 23, 2003
Messages
242
Reaction score
0
Points
0
Age
84
My Satellite Setup
Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
My Location
Benitachell, Alicante, Spain
Glad you got it sorted. As you say, it's an odd one.
 

m_masrougah

Member
Joined
Aug 18, 2008
Messages
1
Reaction score
0
Points
0
Age
44
My Satellite Setup
3 sattelites with diseq
My Location
Egypt
hi,

all the files are in dos format (end of line character is dos not unix) so change it to unix format using the dos2unix command and then change file rights to be executable it should work properly.

Regards
 
Top