You are not logged in.

#1 2017-11-03 21:47:10

mean_booty
Member
Registered: 2016-09-15
Posts: 26

I can't execute shell scripts anymore

I'm not sure when this ocurred, but I recently dowloaded the witcher 2. It was simply a shell script that I had to execute, but when I tried it I got this:

[mean_booty@[excluded] Downloads]$ sudo ./gog_the_witcher_2_assassins_of_kings_enhanced_edition_2.2.0.8.sh 
[sudo] password for mean_booty: 
sudo: ./gog_the_witcher_2_assassins_of_kings_enhanced_edition_2.2.0.8.sh: command not found

It seems to not know how to execute shell scripts. I tested it with a hello world simple shell script and the same thing happened:

[mean_booty@[excluded] Downloads]$ sudo ./hello_world.sh
sudo: ./hello_world.sh: command not found

I think it may be an issue with my paths because typing

bash hello_world.sh

works perfectly.

This is my path output:

[mean_booty@[excluded] ~]$ $PATH
bash: /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl: No such file or directory

Is there a way to "reset" my paths or anything? Is there something on there that shouldn't be or vice versa?

Thanks

Last edited by mean_booty (2017-11-04 17:51:33)


MSI B450I Gaming Plus AC | Ryzen 3600X | 32 GB 3200MHz Micron-E | RX 5700XT Pulse

Offline

#2 2017-11-03 22:08:33

circleface
Member
Registered: 2012-05-26
Posts: 639

Re: I can't execute shell scripts anymore

Why are you running the commands with sudo?  I think the problem is the relative paths, which would obviously be different for the root user.

Offline

#3 2017-11-03 22:30:00

loqs
Member
Registered: 2014-03-06
Posts: 18,859

Re: I can't execute shell scripts anymore

@circleface

$ cat ./hello_world.sh 
#!/usr/bin/bash
echo 'hello world'
$ sudo ./hello_world.sh 
hello world

Offline

#4 2017-11-03 22:41:15

circleface
Member
Registered: 2012-05-26
Posts: 639

Re: I can't execute shell scripts anymore

Thanks loqs, I always thought that wouldn't work, but I guess it does wink

Last edited by circleface (2017-11-03 22:41:28)

Offline

#5 2017-11-04 00:00:58

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: I can't execute shell scripts anymore

I don't think this is a path problem. Please post the output of the following command (in that Downloads directory)

ls -l *.sh

Last edited by 2ManyDogs (2017-11-04 00:01:47)

Offline

#6 2017-11-04 17:55:10

mean_booty
Member
Registered: 2016-09-15
Posts: 26

Re: I can't execute shell scripts anymore

[mean_booty@[excluded] Downloads]$ ls -l *.sh
-rw-r--r-- 1 mean_booty mean_booty 21185760060 Oct 20 16:45 gog_the_witcher_2_assassins_of_kings_enhanced_edition_2.2.0.8.sh
-rw-r--r-- 1 mean_booty mean_booty          81 Nov  3 16:40 hello_world.sh

I just have those two scripts.
If I try to run any shell script not in sudo, it says "permission denied" so that's why I ran these in sudo.

Wouldn't it be either a paths or permissions problem since bash works on its own, but the execution alias doesn't work?


MSI B450I Gaming Plus AC | Ryzen 3600X | 32 GB 3200MHz Micron-E | RX 5700XT Pulse

Offline

#7 2017-11-04 17:56:37

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,694

Re: I can't execute shell scripts anymore

You're trying to execute them, they need execute permissions.

Offline

#8 2017-11-04 19:36:53

glyons
Member
From: Europa
Registered: 2016-10-14
Posts: 37

Re: I can't execute shell scripts anymore

This command will give execute permission for the user that owns the file to your all your scripts in that folder.

$ chmod u+x *.sh

see here
https://wiki.archlinux.org/index.php/Fi … attributes

Offline

#9 2017-11-05 02:34:42

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: I can't execute shell scripts anymore

Typing

bash hello_world.sh

is NOT an equivalent test to

sudo ./hello_world.sh

The latter is not *just* running with sudo, it is also executing the script directly versus running the bash program with a script file... how do you possibly expect to execute a non-executable file???

mean_booty wrote:
[mean_booty@[excluded] Downloads]$ ls -l *.sh
-rw-r--r-- 1 mean_booty mean_booty 21185760060 Oct 20 16:45 gog_the_witcher_2_assassins_of_kings_enhanced_edition_2.2.0.8.sh
-rw-r--r-- 1 mean_booty mean_booty          81 Nov  3 16:40 hello_world.sh

I just have those two scripts.
If I try to run any shell script not in sudo, it says "permission denied" so that's why I ran these in sudo.

Wouldn't it be either a paths or permissions problem since bash works on its own, but the execution alias doesn't work?

No you didn't, you ran an entirely different command in sudo. Also, never run a command with sudo just because you get permission denied. First ask yourself what the command is doing, and why you think sudo might help.

The number 1 cause of people having issues, is because they tried to run a command with sudo without knowing why.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB