Issue with typeset in Linux


 
Thread Tools Search this Thread
Operating Systems Linux Issue with typeset in Linux
# 1  
Old 08-12-2013
Issue with typeset in Linux

Hi All,

typeset -Z4 curtime command is giving different result than expected inside scripts in linux.But it gives expected results outside the scripts.Can you please help us

---------- Post updated at 05:37 AM ---------- Previous update was at 05:25 AM ----------

Code:
curTime=`date +%H%M`
typeset -Z4 fmtCurTime=$curTime
echo $fmtCurTime


Last edited by Scott; 08-12-2013 at 09:18 AM.. Reason: Please use code tags
# 2  
Old 08-12-2013
What symptoms do you have? I have pasted your code into AIX and RedHat Linux without issue, but then I have my shell set as ksh. Doing it in bash gives me the following:-
Code:
bash: typeset: -Z: invalid option
typeset: usage: typeset [-aAfFilrtux] [-p] name[=value] ...

Is this your problem? You don't say, so it's a bit difficult to help. Smilie




Robin
Liverpool/Blackburn
UK
# 3  
Old 08-12-2013
Hi,

We are in Red Hat Linux and ksh.
# 4  
Old 08-12-2013
So, just to be clear,
Quote:
What symptoms do you have?
# 5  
Old 08-13-2013
Hi,

Please try below code in AIX and Red Hat Linux...you will see different results

Code:
typeset -i currentTime=0
currentTime=`date +%H%M`
echo $currentTime

# 6  
Old 08-13-2013
The same output for me. What do you see? What shell are you using on the two servers? Can you paste the output from:-
Code:
ps -f
typeset -Z4 currentTime=`date +%H%M`
echo $currentTime

I've changed the typeset to set a 4 character field padded with leading zeros, because I was running this at 09:25 local time to me, so the output I got was just 925. On both AIX and RHEL, I am using ksh, but if I swap to bash (the default for RHEL) then I get the following output using typeset -i:-
Code:
bash: 0928: value too great for base (error token is "0928")

The -Z flag for typeset is not valid for bash. I've not needed it yet, but it would be good to know of a way to acheive the same effect. Smilie When forcing it in, I get:-
Code:
typeset -Z4 my_var
bash: typeset: -Z: invalid option
typeset: usage: typeset [-aAfFilrtux] [-p] name[=value] ...

Smilie

Can you paste what you are seeing please, because I don't have a problem with your code, other than not knowing if it is three or four digits.



Thanks again,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simple sed command not working; could be a Mac/Linux vs. PC/Linux issue

Hello, I am on a Mac and trying to clean up some monthly files with a very simple SED: sed '3,10d;/<ACROSS>/,$d' input.txt > output.txt (from the input, delete lines 3 - 10; then delete from the line containing <ACROSS> to the end of the file) then output to output.txt Even when I try... (2 Replies)
Discussion started by: verbatim
2 Replies

2. Shell Programming and Scripting

Typeset is not working in Linux korn shell scripting

Hi All, Kindly help on the below issue ASAP. Its very urgent. I have script in which we have below two lines for code and it is not working. Please help. files_to_process=" abc_*.log def_*.log ghi_*.log " typeset -A dir_list ${files_to_process} the script is failing in Linux... (3 Replies)
Discussion started by: tvbhkishore
3 Replies

3. UNIX for Dummies Questions & Answers

Typeset issue

function fxn { echo "target in build_ndm is $target" } function main { target=${server_type} echo "target in main is $target" fxn } In the above the value of target is not being propagated to the function while ideally it should be since typeset variables are visible in sub... (2 Replies)
Discussion started by: sharad.40216
2 Replies

4. Shell Programming and Scripting

Typeset

I don't have man typeset entry in unix. what is the use of typeset command and can you give some examples for that. (1 Reply)
Discussion started by: ramkumar15
1 Replies

5. 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

6. UNIX for Dummies Questions & Answers

Typeset in HP-UX and Linux

typeset -u xname1=$mname1 is working fine in HP-UX. But it throwing below error in Linux: line 40: typeset: -u: invalid option typeset: usage: typeset name . Please suggest. Thanks, Ambar (5 Replies)
Discussion started by: ambarginni
5 Replies

7. 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

8. 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

9. Shell Programming and Scripting

typeset

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

10. 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
Login or Register to Ask a Question