I am having a problem with typeset command:
It is behaving differently in different machines.
Machine 1:
/marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>echo $0
-bash
/marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>vi fn2.ksh
########################################################################################################
typeset -ux CONTROL_DB=$1
export TIMESTAMP=`date +%H%M%S%d%m%y`
echo $CONTROL_DB $TIMESTAMP
########################################################################################################
/marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>fn2.ksh hi
./fn2.ksh: line 2: typeset: -u: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
095741061010
Machine 2:
/marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>echo $0
-ksh
/marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>vi fn2.ksh
########################################################################################################
typeset -ux CONTROL_DB=$1
export TIMESTAMP=`date +%H%M%S%d%m%y`
echo $CONTROL_DB $TIMESTAMP
########################################################################################################
/marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>fn2.ksh hi
HI 114544061010
Can anyone help me in solving this......
clx
October 6, 2010, 7:12am
2
You have different flavors.
first one seems to be linux/gnu on which -u option is not available.
methyl
October 6, 2010, 7:30am
3
Or more importantly "Machine 1" is running the script under "bash" and "Machine 2" is running the script unide "ksh".
Though the script name is "fn2.ksh" this is just a name. It would need a shebang line to force "ksh" if "ksh" is available on "Machine 1"
What do you mean by 'shebang' line?
---------- Post updated at 05:36 PM ---------- Previous update was at 05:35 PM ----------
How can i find the flavour that i am using?
clx
October 6, 2010, 8:12am
5
type uname or uname -a
shebang is the special syntax as the first line of the script which tells in which environment the script should execute.
something like,
#! /usr/bin/bash will execute the script in bash shell.
in the same way #! /usr/bin/ksh for korn shell.
type uname or uname -a
shebang is the special syntax as the first line of the script which tells in which environment the script should execute.
something like,
#! /usr/bin/bash will execute the script in bash shell.
in the same way #! /usr/bin/ksh for korn shell.
HI,
When i put 'echo $0', my output is '-bash'.
So i appended the shebang as '#! /usr/bin/bash' , it didnt work. But when i append '#! /usr/bin/ksh' it working fine.
Why is it so? My machine is in '-bash' only Right? Then why it is working after appending '#! /usr/bin/ksh' to it?
methyl
October 6, 2010, 10:31am
7
There is no "-u" switch in the "bash" version of "typeset". Hence the syntax error. The shebang line forced "ksh" which allows "-u" in the "typeset" command.
There are many differences between "bash" and established unix shells.