Page 1 of 1

what am I missing??? [Solved]

Posted: 05 May 2014, 03:23
by Ed_P
If I run this command via lxterminal I get this output:

Code: Select all

root@porteus:/home/guest# ls -R /mnt/live/memory/changes/home
/mnt/live/memory/changes/home:
guest/

/mnt/live/memory/changes/home/guest:
Backups/  Downloads/  mychanges.sh

/mnt/live/memory/changes/home/guest/Backups:
FireFox/

/mnt/live/memory/changes/home/guest/Backups/FireFox:

/mnt/live/memory/changes/home/guest/Downloads:
java-builder/  p11-kit-compat32-0.16.4-x86_64-1compat32.txz

/mnt/live/memory/changes/home/guest/Downloads/java-builder:
root@porteus:/home/guest# 
If I run the same command via a script in lxterminal I get this:

Code: Select all

guest@porteus:~$ ./mychanges.sh
bash: ./mychanges.sh: Permission denied
guest@porteus:~$ su
Password: 
root@porteus:/home/guest# ./mychanges.sh
bash: ./mychanges.sh: Permission denied
The mychanges.sh script:

Code: Select all

#!/bin/sh
ls -R /mnt/live/memory/changes/home
What am I doing wrong?? :wall:

Re: what am I missing???

Posted: 05 May 2014, 03:34
by Slaxmax

Code: Select all

guest@porteus:~$ sh mychanges.sh
or
enable your script to executable

Code: Select all

root@porteus:/home/guest# chmod +x mychanges.sh
and run normally

Code: Select all

guest@porteus:~$ ./mychanges.sh

Re: what am I missing???

Posted: 05 May 2014, 04:17
by Ed_P
Slaxmax wrote:

Code: Select all

guest@porteus:~$ sh mychanges.sh
This works. :good:
or
enable your script to executable

Code: Select all

root@porteus:/home/guest# chmod +x mychanges.sh
Actually I did do this initially.

Code: Select all

guest@porteus:~$ chmod +X mychanges.sh
guest@porteus:~$ ./mychanges.sh
bash: ./mychanges.sh: Permission denied

Re: what am I missing???

Posted: 05 May 2014, 14:20
by brokenman
sh mychanges.sh
This works
Wasn't this suggested in an earlier (different) thread?
Actually I did do this initially.
Yes but you used a capital 'X' where the instruction suggested a lower case 'x'

One of the security aspects of linux is that a script must have the executable bit set in order to execute. This is so you can't download something that will run and do something nasty. It is akin to windows making you confirm that you really want to run this executable, only more secure (IMHO). So for future reference after creating a script that you want to call directly, you need to issue: chmod +x myscript.sh

Actually you don't really need the .sh as linux doesn't care about file extensions, but it helps to let YOU know that this is a script.

Re: what am I missing???

Posted: 05 May 2014, 14:49
by Ed_P
Image Thank you brokenman.

I just signed on to update this thread with [Solved] and see your posting.

Yes, I figured out that Linux didn't like my capital X and that was my problem. I eventually reran the command with a lower case x and now the script runs normally. Stupid Linux. (Windows doesn't have this uppercase / lowercase problem.)

Yes, preceeding the run command with sh worked and you suggested it in a prior post, but I have a dozen little scripts that I run that don't require the preceeding sh to run and that is why this situation was confusing me. I've experienced the uppercase/lowercase sensitivity of Linux with file names and directory names before but not in a command parameter before and since Windows doesn't have this problem it didn't occur to me. Image And since it was late the eyes were tired.
Actually you don't really need the .sh as linux doesn't care about file extensions, but it helps to let YOU know that this is a script.
Now this idea I like a lot. Image

Thanks again brokenman. :friends: