I was writing a Bash shell script that will be executed on both an AIX server (/usr/bin/ksh) and a SLES server (/bin/bash). The AIX server
has Bash installed at "/usr/bin/bash", which is in a different dir then the SLES server.
So basically I am writing the script on the SLES server using Gedit, really just because the AIX version of vi is so dreadfully painful to
use... Then transferring the file to the AIX server. But when I transfer from the SLES to the AIX server I need to change the Shebang
line depending upon which server the script is being executed on.
Is it possible to do something like this, instead of needing to manually change the location of the interpreter?
So is something like that possible? If not its fine... I guess I could just make a symbolic link on one of the servers so I could just keep it
the same, but was curious so I thought I'd ask.
I don't think this is possible.
However a little bit of lateral thinking here.
Save the file twice but with differing filenames one containing #!/bin/bash and the other with #!/usr/bin/bash as the shebang...
Write a simple third script with a shebang line as #!/bin/sh to detect which bash and autolaunch your required script with or without a separate terminal...
(If this makes sense.)
Just an idea...
This User Gave Thanks to wisecracker For This Post:
You can use the env command in your shebang line. I write scripts for Solaris, AIX, and Linux and using that command will locate the interpreter on the given system:
These 2 Users Gave Thanks to in2nix4life For This Post:
Hey guy's, thanks for the replies. Much appreciated...
Some good ideas, thanks.
I decided to just go simple and create a symbolic link on the AIX server.
Seems to have done the trick. Don't know why I didn't think of that before...
OS : RHEL / Oracle Linux 6.8
In bash shell, how can I replace a character under the cursor with another character ?
In the below example , after I typed the following line, I realized that I meant 7013 and not 2013. So I move the cursor to the left and keep it on top of 2 (of 2013) and I want... (7 Replies)
Hi all, I'm new to shell script
i wrote some shell script for my colleague, everyone is fine,except on user
we are using VNC viewer to work
and there are some script start with shebang #! /bin/csh
there is an user will not terminate after running the script even if a hello world
i need... (5 Replies)
Hello,
I'm works on Ubuntu server
My goal : I would like to read file line per line, but i want to started at the end of file.
Currently, I use instructions :
while read line;
do
COMMAND
done < /var/log/apache2/access.log
But, the first line, i don't want this. The file is long... (5 Replies)
Hi All,
Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool.
Wraper script am trying is to do with above metion 2 files.
utility tool accepts :
a. userinfo file : which contains username
b. item file : which... (2 Replies)
I would like to the the windws8/cygwin/bash shebang feature to start a powershell script.
I do a "chmod +x set-sound.ps1"
and then at a bash prompt I do
./set-sound.ps1
The first line of ./set-sound.ps1
#!powershell.exe -ExecutionPolicy unrestricted
The result is the result:
... (5 Replies)
Hi ,
I know about the shebang line in shell scripting. Just want to know whether is there any difference in execution of the program by keeping and not keeping the shebang line. Because without shebang line also the script is working. correct me if am wrong. Any help on this will be helpful (5 Replies)
Hi,
As per my understanding, we can use two shebang statements in a single shell script. Please see below snippet-
#!/bin/bash
.......## some code A
#!/bin/csh
.......## some code B
exit 0;
Here, code A will be executed using bash shell and code B will be executed with c shell.
... (9 Replies)
#!/bin/ksh
echo -en "\033|||'-'))
echo -e "\033
The above script works fine when the interpreter is ksh, but outputs the following error when #!/bin/bash is used as shebang:
test.sh: line 5: syntax error near unexpected token `('
test.sh: line 5: `case "$ACTIVATION_KEY" in +(|||'-'))' (2 Replies)
Can any one tell me how to replace a shebang line of a file using sed?
Eg: If a file contains the following shebang line
#!C:/InstantRails/ruby/bin/ruby
I would like to replace it with
#!/usr/local/bin/ruby
The shebang line of the file can be obtained from the command
cat... (3 Replies)
Do we need to include the exclamatory mark in the shebang line??:confused:
What if we dont include it??:eek:
Actually what shebang line implies when we run a script??
shebang line--> #!/bin/ksh :p (6 Replies)