Tag Info

New answers tagged

0

It is too basic to ask about it, but does the script have execution right? Can be added by chmod +x script.sh. And do You run it from the directory containing the script by ./script.sh?


0

This can also be caused by a BOM in a UTF-8 script. If you create the script in windoze sometimes you get some junk at the start of the file.


6

This usually happens when the shebang (#!) line in your script is broken. The shebang is what tells the kernel the file needs to be executed using an interpreter. When run without sudo, the message is a little more meaningful. But with sudo you get the message you got. For example: $ cat test.sh #!/bin/foo echo bar $ ./test.sh bash: ./test.sh: /bin/foo: ...


0

As I have posted in the other question, sometimes it is possible to get the file not found error even when you execute the script as ./scriptname. As I have posted in the other answer, you can test it in your machine. Testing cat ksh_experiment.ksh #!/usr/bin/ksh echo "Hello" Now after providing the permissions when I ran the file, it produced the ...


3

When you type a command, the shell looks up the command from a list of directories, as specified by the PATH variable. The current directory is not in PATH by default (for security reason), so the shell can not find your script. Using ./, meaning the current directory, so the shell knows where is your script.


6

Try "./a.sh" when trying to execute it. It needs to know where the file is at. The './' tells it to look in the current directory.


2

You have a space instead of a forward slash here: #! /bin bash Should be: #! /bin/bash The shebang (#!) should be followed by the path to an executable, which may be followed by arguments, e.g.: #!/usr/bin/env sh In this case /usr/bin/env is the executable, see man env for details. But just /bin refers to a directory.


4

The test is done by compiling a small dummy C program and by checking how the compiler names the output file. The following example is a simplified version of what configure is doing #!/bin/sh cat << EOT > dummy.c int main(int argc, char ** argv) { return 0; } EOT gcc -o dummy dummy.c if [ -f dummy.exe ] ; then # exe fi I would suggest ...


-1

This will give you the extension of the file: FILENAME=/tmp/testfile.exe echo "${FILENAME##*.}" result: exe


0

. is the symbol for your current directory. You have to include the / so it knows that it's not a . at the beginning of the file. If you navigate to a different directory and type the directory of the file, you don't have to have the ./


0

If you run echo $PATH you will see a list of directories that your system will search for commands to run. If you want to run commands in your current working directory, then you can run: PATH=$PATH:.;export PATH You can add this line to your ~/.bash_profile to have this behaviour persistent across sessions.


3

You have to create a "Desktop Entry" like this (no tested): #!/usr/bin/env xdg-open [Desktop Entry] Encoding=UTF-8 Type=Application X-Created-By= name Icon= icon Exec="path_of_file" %u Name=name of program



Top 50 recent answers are included