different behaviour for ksh and ksh -x


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting different behaviour for ksh and ksh -x
# 1  
Old 04-11-2011
different behaviour for ksh and ksh -x

I'm getting different behaviour when executing below script in debug option.
Code:
$ cat ss.ksh
ff=$(pwd)
echo " ff : $ff"
$ ksh ss.ksh
 ff : /tmp
$ ksh -x ss.ksh
+ + pwd
ff=
+ echo  ff : 
 ff :

I was getting this behaviour in my actuall script i'm able to reproduce this in simple script also.

This behaviour is also different for having
Code:
#!/bin/ksh

and
Code:
#!/bin/ksh -x

in the first line of ss.sh script.

btw, I'm working in Solaris 10.

thz in advance.
# 2  
Old 04-11-2011
I cannot reproduce it:

Code:
$ cat ss.ksh
ff=$(pwd)
echo " ff : $ff"
$ ksh -x  ss.ksh
+ + pwd
ff=/tmp
+ echo  ff : /tmp
 ff : /tmp
$ ksh   ss.ksh
 ff : /tmp
$ uname -sr
SunOS 5.10

# 3  
Old 04-11-2011
Neither do I:
Code:
$ uname -a
SunOS s10u9 5.10 Generic_142910-17 i86pc i386 i86pc
$ cat /etc/release
                    Oracle Solaris 10 9/10 s10x_u9wos_14a X86
     Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
                            Assembled 11 August 2010
$ what /bin/ksh
/bin/ksh:
        Version M-11/16/88i
        SunOS 5.10 Generic 141589-04 May 2010
$ cat ss.ksh
ff=$(pwd)
echo " ff : $ff"
$ ksh ./ss.ksh
 ff : /tmp
$ ksh -x ./ss.ksh
+ + pwd
ff=/tmp
+ echo  ff : /tmp
 ff : /tmp

# 4  
Old 04-11-2011
The OP could try to trace the execution to check if the additional information could help.

If truss is available:

Code:
truss ksh -x ss.ksh

# 5  
Old 04-12-2011
i'm sorry for wasting every'1 time. the problem is /tmp was not having enough it was having only 600 bytes free. After increasing /tmp free space everything is working.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Behaviour of pwd command in sh and ksh

I have a script as below. bash-3.00$ cat test.sh #!/usr/bin/ksh path=`pwd` echo $path var=$path/temp11 echo $var If run it is giving output bash-3.00$ ksh test.sh //var/tmp/SB2/miscellaneous //var/tmp/SB2/miscellaneous/temp11 (5 Replies)
Discussion started by: millan
5 Replies

2. UNIX for Dummies Questions & Answers

Difference Between executing llike ./myscript.ksh and . ./myscript.ksh

Hi , What is the diffence between executing the script like ./myscript.ksh . ./myscript.ksh I have found 2 difference but could not find the reason 1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
Discussion started by: max_hammer
5 Replies

3. Shell Programming and Scripting

KSH: Confused with behaviour of exit

Hi Everyone, I am confused on why the below snippet of code is not working as I intend it to do. I have googled and confirmed that "exit" is supposed to abort the execution of the script regardless if the exit was called from inside a function, or the main body of the script. log_and_die() { ... (3 Replies)
Discussion started by: maddmaster
3 Replies

4. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

5. UNIX for Advanced & Expert Users

Strange KSH behaviour - any comments?

As you are probably aware, $# indicates the number of parameters passed into a korn shell script. But this appears to hang around for sunsequent runs...???? A simple script:- #!/usr/bin/ksh echo "#parameters $#" echo "\$1 $1" echo "\$2 $2" I run the script with 0 parameters (all fine) #... (7 Replies)
Discussion started by: gsw_aix
7 Replies

6. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

7. UNIX for Dummies Questions & Answers

Longer commands and strange behaviour on ksh

Hi, I was trying to customize this archaic HP-UX box. only shell available is ksh and that too seems to be pretty old and doesn't completely conform to what I read on the web about ksh. Anyway here are my issues: - I wanted to have a dynamic title on xterm or dtterm. I put the following lines... (2 Replies)
Discussion started by: anurags
2 Replies

8. Shell Programming and Scripting

tracing a ksh script within a ksh script

I normally trace a script with the ksh -x <script name> and redirect strderr to file. But if you have a script like the examble below...... vi hairy bear=`grep bear animals` if then ksh more_animals fi If I ksh -x hairy it won't trace "more_animals" unless I put a -x in it. Is... (1 Reply)
Discussion started by: shorty
1 Replies

9. Shell Programming and Scripting

executing a ksh script from another ksh script

Hi, I'm new to unix scripting.How can i call a script from another script. I have a.ksh and b.ksh .I have to call b.ksh from a.ksh after it is successfully exceuted. I tried using #!/bin/ksh -x in a.ksh and at the end i have used /path/b.ksh My problem is it is executing only a.ksh.it... (6 Replies)
Discussion started by: ammu
6 Replies

10. Shell Programming and Scripting

Not another ksh!

Hi there, I've coded a script to create a menu system on an AIX machine. When user selects an item of the menu I perform a program using " nohup somepgm &" The reason I do that is because usually the scripts behind the menu items are very time-consuming and users logout and log back in... (2 Replies)
Discussion started by: Shaz
2 Replies
Login or Register to Ask a Question