There is a space before the shebang on the first line. The OS I'm using is Kali (the new Rolling version) which I believe by default uses Bourne again shell as the interpreter. Also, the way that I wrote the shebang with the space leading has always been how I've always written it. I didn't know that it made a difference for there to be a space?? But I'm new at this, also. And thank you for clarifying about the test statements, that was very helpful. So should the shebang not have a space in front of it?? If I were to use this script on a different OS that doesn't use bash, and that space were there before the shebang, would that different OS not know what interpreter to use?? Again, thank you for your time.
I repeat: " Unless #!interpreter_path starts in column 1 on the 1st line in your file, that line is just a comment and has absolutely no effect on what interpreter will be used to run your script." A leading space makes a HUGE difference. Any attempt on any UNIX-like operating system to exec a shell script that does not have #! as the 1st two characters in that file will be run by that system's default shell.
If the #!/interpreter/path start in the 1st character of the 1st line of your file and the operating system doesn't find an executable file with that path, you're likely to get a cryptic message like:
(assuming that your login shell is bash and the name of the shell script you were trying to execute was named script_file).
With the space there, another operating system (or your own) will know exactly what shell to use to invoke your script (that system's default) which will probably be named sh and might or might not be linked to bash, ksh, dash, ..., or a 1970's vintage pure Bourne shell depending on what operating system you are using at the time.
Of course, you can always use:
to have bash run script_file no matter what the first line of script_file looks like.
This User Gave Thanks to Don Cragun For This Post:
Hi,
I am a newbie here. Trying to find a way of writing a script to launch multiple terminal or console windows on solaris 9. I used to be able to do this using cmdtool on older versions of solaris and it was even possible to configure the size and screen position of the window and the title. ... (5 Replies)
I developed a script in Lingon (which is an automated script editor developed for OS X) that is used to automatically restart programs only if they crash. The script itself does just that, but I only want it to load if I'm going to use the specific application that it's designed to protect. In... (3 Replies)
I developed a script in Lingon (which is an automated script editor developed for OS X) that is used to automatically restart programs only if they crash. The script itself does just that, but I only want it to load if I'm going to use the specific application that it's designed to protect. In the... (2 Replies)
i wanted to execute some terminal commands on local linux, parse their output and display it to the user, i checked netcat source code but i couldnt understance it since im new to c (and linux at the same time).
so i was wondering if there is away to run an instance of terminal hidden, read and... (15 Replies)
Hello,
I have a PERL-TK based GUI from which I want to launch a command on an existing UNIX terminal (this is also the parent terminal for this perl based gui window). The command I want to launch is interactive (there is no intention to interact with that command from the same PERL gui i.e. no... (2 Replies)
After I installed OS X Lion I haven't been able to launch x11 remotely (using ssh) from Terminal.
It works fine locally, and also remotely directly from the Xterm.
I log in to the unix server at my university from the terminal like this:
ssh -l -X login@host.com
This used to launch... (1 Reply)
After installing centos iam not able to see the terminal icon in the applications menu to launch the command prompt in Centos.
However iam able to see the Open Terminal menu, when i right click and it is not working.
let me know what are the things i need to check.:b: (1 Reply)
So, I'm in a graphical terminal (xfce4-terminal) and I was wondering, would there be a way to type a command, and it run in a new terminal window?? An example would be like, say that I want to open a .txt file, but I want it in a different window, instead of the one that I'm currently using because... (1 Reply)
Hello All,
I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly.
Is there any way to take the output from the cat... (7 Replies)