One thing I have done over the years is create a standard set of libraries that I source near the top of my scripts with something like this:
Within that library file I have something like this:
Unfortunately, I don't know of a way to dynamically change the "shebang" line since it is the first line of the script. You could potentially use a wrapper that uses a shell that you know is always available which then calls your other scripts using the preferred and available shell.
I understand not having the same shells available when you have multiple platforms (i.e. Solaris, HP-UX, Linux, etc.), but I would be concerned if you have systems that are the same platform and version but with different installation standards. This is especially true in a large data-center. Also, if you know that systems will not all have the same shells, I would recommend using the least common denominator. So if the all have sh or csh, I would write my scripts using one of those.
I'm new to scripting and I need help with a bourn shell script. What i'm trying to do is a test condition where "if the time is within 2 hours, it's true" and so on.
The time is in the following format
DATE=`/bin/date +"%Y%m%d%H%S"`
for example, 20060907152000.
So, what the script first... (9 Replies)
Hello,
I am trying to accomplish the following.
Send the output of a command to the screen (this happens by default) as well as capture the output of the screen to a log file.
How can this be achieved in DOS command interpreter syntax.
Any ideas/suggesstions/indicators are greatly... (2 Replies)
What is the difference between the(a) shell and the (a) command-line interpreter?
Here we're talking about the complete dummy question, but could someone point me right.
(yes, have written scripts in for instance bash shell,
and and grepp-ed my way around ....:eek: (4 Replies)
I am new to BASH and writing a small script to identify the SHELL .
#!/bin/bash
BASH='/bin/bash'
KSH='/bin/ksh'
if
then
echo "it's Bash"
else
echo "it's not Bash"
fi
$ bash -x a.sh
+ BASH=/bin/bash
+ KSH=/bin/ksh
+ ''
a.sh: line 4:
where am I missing . PLease advice . (10 Replies)
I need clarification in -a test.
If say, in test -a left expression is not present but the right expression is present, do the shell will consider the left expression true and evaluate the right expression?
For example:
if ]
then
rm -f ${file}
fi
Is this test condition... (7 Replies)
I want to test connectivity between different servers with my server using information as IP and port only.
I have Name,IP List and port in one file. Please help how i can test connectivity is successful or not?
File format will be:
Name1,127.0.0.1,80
Name2,127.0.0.2,8080
Output could be ... (1 Reply)
I am looking for a simple BASIC Interpreter written in a shell scripting language.
For me something like this would be a great learning tool...
After much goggle eyed Googling I came upon this:-
https://gist.github.com/cander/2785819
It is small and I haven't tried it yet as I am at work... (6 Replies)
Dears ,
kindly I wanna do test for one KSH script to know how is it working , the problem that I'm facing is whenever put "sh -x ./my_script.sh"
the output seems very long & although I tried to to redirect it to files as it shown , but it failed :eek: :-
sh -x ./my_script.sh >... (2 Replies)
Hello. We have recently changed from HP Unix Servers to Solaris. On the HP Severs we were using the POSIX shell. Solaris is using the Bourne sh.
We are using ksh as our default shell after login. The problem we are encountering is when something like Perl or Cron uses the shell to execute a... (5 Replies)
Hi all and apologies for the silly question, but I've searched and I can't get this right.
I have a list of email addresses in a file that I need to blacklist (spam). the list is quite long and I would need to script a small routine so that I can get the following for each line in the file:
db... (4 Replies)