04-09-2011 02:27 PM
I am writing a script that work perfectly well in linux environment as it will run
Is there an HPUX equivalent as I need to include that file to the script?
Solved! Go to Solution.
04-09-2011 02:43 PM
> I am writing a script [...]
With my weak psychic powers, I can't see it.
I can't even see its first line (the line
with the "#!").
> [...] linux environment [...]
> Is there an HPUX equivalent [...]
No, but there's probably a _shell_
equivalent, if only we knew which shell(s)
you were using. if "source" doesn't work in
your shell, then I'd suggest ".":
04-09-2011 05:51 PM
Run what how, with . before what???
What, exactly, did this contribution actually
contribute here? Was your dot easier to read
than my dot? (And I thought that _I_ had too
much time to kill.)
04-10-2011 07:39 AM
On Linux and Apple systems, the 'bash' shell is the default shell. As such it has the 'source' as well as the 'dot' command, both of which do the same thing.
HP-UX's default shell is a POSIX shell closer to the Korn shell and found in '/usr/bin/sh' or '/sbin/sh' for 'root'. You can still specify an interpreter ("she-bang") line of simply '/bin/sh' since this is a symlink to '/usr/bin/sh' in HP-UX.
If you want to include a file (very commonly variable declarations and assignments) into another script, you speak of "sourcing" or reading it with the 'dot' command:
# include the "mystuff' file here:
echo "now continuing..."
Notice the 'dot' followed by whitespace, followed by the file to be included ('sourced' or read, whatever term you prefer).
04-10-2011 11:50 AM
> As mentioned, "source" is used by the scummy C shell and its descendants. A real shell uses "." to source files.
While I wholly agree, when it comes to the "scummy C shell and its descendants", I'd certainly consider the Bash shell to be a "real shell" that can use *either* the 'source' command or the 'dot' command to achieve the same result.
04-10-2011 11:15 PM
I have tried the . dot to source file but it doesn't seem to work in my HPUX but work fine in Linux.
I get the the config.txt not found error. Any idea why
04-11-2011 12:15 AM
>I get the the config.txt not found error.
Why aren't you using an absolute path to config.txt?
Either it must be in $PATH or it must absolute or relative.
04-11-2011 12:24 AM
for example, script.sh config.txt
it make the maintenance easier as I only need one script but many config.txt to cater for different server