Error while using typeset command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while using typeset command
# 1  
Old 10-06-2010
Error while using typeset command

I am having a problem with typeset command:
It is behaving differently in different machines.

Machine 1:
Code:
 
 
/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:

Code:
 
/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......
# 2  
Old 10-06-2010
You have different flavors.
first one seems to be linux/gnu on which -u option is not available.
# 3  
Old 10-06-2010
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"
# 4  
Old 10-06-2010
What do you mean by 'shebang' line?

---------- Post updated at 05:36 PM ---------- Previous update was at 05:35 PM ----------

Quote:
Originally Posted by anchal_khare
You have different flavors.
first one seems to be linux/gnu on which -u option is not available.

How can i find the flavour that i am using?
# 5  
Old 10-06-2010
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.
# 6  
Old 10-06-2010
Quote:
Originally Posted by anchal_khare
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?
# 7  
Old 10-06-2010
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Typeset builtin error

I'm attempting to emulate another users .zshrc file. However, I'm sort of confused on what exactly the -g argument does for the typeset builtin. Here's what he has in his .zshrc file: typeset -ga sources sources+="$ZSH_CONFIG/environment.zsh" sources+="$ZSH_CONFIG/options.zsh"... (4 Replies)
Discussion started by: brandontdr
4 Replies

2. Shell Programming and Scripting

Typeset command issue

Hi, As per my understanding typeset wil lmake a variable constant or readonly and -i option will make a variable integer. But please see the below outputs typeset -i abc=000001;echo $abc 1 typeset -i abc=0000010;echo $abc 8 typeset -i abc=00000100;echo $abc 64 typeset -i... (3 Replies)
Discussion started by: ratheeshjulk
3 Replies

3. Shell Programming and Scripting

Struck with Typeset Command

Can someone explain whats this below command will do exactly.. typeset tmpFile1 tmpDir1 rc fileName fullName bc typeset tmpFile1 tmpFile2 rc fileSuffix uef typeset origFile bc fullName tmpDir1 remoteCmd inFile newInFile typeset num fn curDate fileSuffix ucFileName Since i'm new to... (1 Reply)
Discussion started by: help_scr_seeker
1 Replies

4. Shell Programming and Scripting

how the typeset command works in shell script

typeset -l section section=${2:-.} what does these 2 lines meaning? (1 Reply)
Discussion started by: venkatababu
1 Replies

5. UNIX for Dummies Questions & Answers

Typeset

Hi, Can any one please explain me the use of 'typeset' in shell scripting? I donot under stand the use and advantages of using typeset. In one of our script, it is written like typeset VERBOSE NO_UPDATE typeset LOAD_SYBASE_TABLES I donot understand what actually these lines do. As per my... (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

6. UNIX and Linux Applications

typeset-r

Hi All , Can any one help me the meaning of typeset -r Thanks, venkat (1 Reply)
Discussion started by: venkatakotiy
1 Replies

7. Shell Programming and Scripting

typeset

Can anyone show me a simple practical usage of typeset. (1 Reply)
Discussion started by: balaji_prk
1 Replies

8. UNIX for Dummies Questions & Answers

typeset and export command difference

Can anyone please explain what the difference is between these two commands typeset - ? export - i know with this even child process can read the variable Declare - ? i use bash shell http://cnswww.cns.cwru.edu/~chet/bash/bashref.html#SEC58 states that " The typeset command is... (0 Replies)
Discussion started by: systemsb
0 Replies

9. Shell Programming and Scripting

typeset -f ???

I have found this command *typeset* and the option * -f *, which should provide me the list of all the currently defined functions. Is there any possibility of specifying the file in which this command to search ? (1 Reply)
Discussion started by: xinfinity
1 Replies

10. UNIX for Dummies Questions & Answers

TYPESET use

Hi all, I have problem understanding shell script.Written that $bindir/put_load.ksh ; typeset RV= $? I dont have any other document about script. How can i find that $bindir is exist or not what is the content of that, i am working on new box . how can i search that in old box what... (4 Replies)
Discussion started by: sam71
4 Replies
Login or Register to Ask a Question