Hello folks. I am new to this list, and pretty new to programming/scripting and Linux/Unix in general. So I beg your patience and your assistance. I have written a simple script that I want to execute as a cgi script called from a web page. When I run the code by copying and pasting it in an open shell session, it executes just fine, but when I try to execute it as a command within the shell or call it from a web page, it fails. The first line of my script is #!/bin/bash and I have tried to execute my script by typing: xxx.cgi I get bash: xxx.cgi command not found . xxx.cgi I get bash: .xxx.cgi command not found I have played fith file permissions on my script and have it set to SUID: -rwsr-xr-x I am not sure it my problem is script related or permissions related...or something else entirely. I wrote it in bash since bash seems to be the default shell. Any suggestions? Thanks. Vacme
Veronica Hernandez wrote:
The first line of my script is #!/bin/bash
and I have tried to execute my script by typing: xxx.cgi I get bash: xxx.cgi command not found . xxx.cgi I get bash: .xxx.cgi command not found
Have you tried ./xxx.cgi ? The ./ specifies that you should run the script/program in the current directory rather than look for it in $PATH. To list the PATH, use # echo $PATH and to change it, use # export PATH=/home/xyz/bin:$PATH That one makes /home/xyz/bin programs executable from a shell (before any program with the same name in (say) /usr/bin You can put these commands in ~/.bashrc (path_to_your_home_directory/.bashrc) to have them available in every bash shell. Some versions of SuSE make all files in the current directory executable. This makes programming easier and avoids some problems (such as what happens if you try to execute a script you called test without using ./test) but is a security risk because it's also an excellent way of getting you to run a trojan horse program. I disable this feature when I have it. Root should never have this feature. -- JDL
Veronica Hernandez wrote:
The first line of my script is #!/bin/bash
and I have tried to execute my script by typing: xxx.cgi I get bash: xxx.cgi command not found . xxx.cgi I get bash: .xxx.cgi command not found
Have you tried ./xxx.cgi ? The ./ specifies that you should run the script/program in the current directory rather than look for it in $PATH. To list the PATH, use # echo $PATH and to change it, use # export PATH=/home/xyz/bin:$PATH That one makes /home/xyz/bin programs executable from a shell (before any program with the same name in (say) /usr/bin You can put these commands in ~/.bashrc (path_to_your_home_directory/.bashrc) to have them available in every bash shell. Some versions of SuSE make all files in the current directory executable. This makes programming easier and avoids some problems (such as what happens if you try to execute a script you called test without using ./test) but is a security risk because it's also an excellent way of getting you to run a trojan horse program. I disable this feature when I have it. Root should never have this feature. -- JDL
Veronica Hernandez writes:
Hello folks.
I am new to this list, and pretty new to programming/scripting and Linux/Unix in general. So I beg your patience and your assistance.
I have written a simple script that I want to execute as a cgi script called from a web page. When I run the code by copying and pasting it in an open shell session, it executes just fine, but when I try to execute it as a command within the shell or call it from a web page, it fails.
The first line of my script is #!/bin/bash
and I have tried to execute my script by typing: xxx.cgi I get bash: xxx.cgi command not found . xxx.cgi I get bash: .xxx.cgi command not found
First of all is this called from a web server? If so you must setup apache to look in the right place for cgi scripts. In /etc/httpd/conf/httpd.conf you will find something like: ScriptAlias /cgi-bin/ "/opt/share/httpd/cgi-bin/" Change to where you expect the scripts to be. I believe it must be under the same directory as the document's root. If you are just trying to execute this in the shell then I will try not to overlap John's response. Check the permissions on the directory where the file is stored. The execute bit must be on for the user. Here is a directory I store stuff in: drwxrwxrwx 2 jlm dev 1112 Nov 14 15:54 /home/jlm/bin If the execute bit on the directory is not on then nothing in the directory is allowed to execute.
I have played fith file permissions on my script and have it set to SUID: -rwsr-xr-x
I am not sure it my problem is script related or permissions related...or something else entirely.
I wrote it in bash since bash seems to be the default shell.
Any suggestions?
Thanks.
Vacme
participants (3)
-
Jesse Marlin
-
John Lamb
-
Veronica Hernandez