Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

ksh script failed while using -x

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 09-21-2012
yoavbe yoavbe is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 9 April 2013, 8:13 AM EDT
Posts: 70
Thanks: 4
Thanked 0 Times in 0 Posts
ksh script failed while using -x

Hi,
I have a Kshell script that is failed if i am using the -x option.


Code:
$ cat ListOfFiles.lst
\+DATA_DM01/pudwh/datafile/dw_billing_tts_1                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_2                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_3                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_4                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_5                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_6                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_7                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_8                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_9                                     
\+DATA_DM01/pudwh/datafile/dw_billing_tts_10                                    
\+DATA_DM01/pudwh/datafile/dw_billing_tts_11                                    
\+DATA_DM01/pudwh/datafile/dw_billing_tts_12                                    
\+DATA_DM01/pudwh/datafile/dw_billing_tts_13                                    
\+DATA_DM01/pudwh/datafile/dw_billing_tts_14                                    
\+DATA_DM01/pudwh/datafile/dw_billing_tts_15                                    
\+DATA_DM01/pudwh/datafile/dw_billing_tts_16                                    
\+DATA_DM01/pudwh/datafile/dw_billing_tts_17 

cat test1.ksh
#!/bin/ksh
cat /home/oracle/ListOfFiles.lst
set -A FILE $(cat /home/oracle/ListOfFiles.lst)
echo FILE=${FILE[@]}
echo ${FILE[@]} | sed 's/ /,/g' | sed 's/\\//g' > /home/oracle/ListOfFiles.tmp

while executing the script WITHOUT the -x it finished successfully:
cat /home/oracle/ListOfFiles.tmp
+DATA_DM01/pudwh/datafile/dw_billing_tts_1,+DATA_DM01/pudwh/datafile/dw_billing_tts_2,+DATA_DM01/pudwh/datafile/dw_billing_tts_3,+DATA_DM01/pudwh/datafile/dw_billing_tts_4,+DATA_DM01/pudwh/datafile/dw_billing_tts_5,+DATA_DM01/pudwh/datafile/dw_billing_tts_6,+DATA_DM01/pudwh/datafile/dw_billing_tts_7,+DATA_DM01/pudwh/datafile/dw_billing_tts_8,+DATA_DM01/pudwh/datafile/dw_billing_tts_9,+DATA_DM01/pudwh/datafile/dw_billing_tts_10,+DATA_DM01/pudwh/datafile/dw_billing_tts_11,+DATA_DM01/pudwh/datafile/dw_billing_tts_12,+DATA_DM01/pudwh/datafile/dw_billing_tts_13,+DATA_DM01/pudwh/datafile/dw_billing_tts_14,+DATA_DM01/pudwh/datafile/dw_billing_tts_15,+DATA_DM01/pudwh/datafile/dw_billing_tts_16,+DATA_DM01/pudwh/datafile/dw_billing_tts_17

While it running with -x option it faild .
Please advise


Code:
sh -x test1.ksh
++ cat /home/oracle/ListOfFiles.lst
+ set -A FILE '\+DATA_DM01/pudwh/datafile/dw_billing_tts_1' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_2' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_3' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_4' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_5' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_6' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_7' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_8' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_9' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_10' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_11' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_12' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_13' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_14' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_15' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_16' '\+DATA_DM01/pudwh/datafile/dw_billing_tts_17'
test1.ksh: line 3: set: -A: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]

Thanks

Last edited by Corona688; 09-21-2012 at 03:17 PM..
Sponsored Links
    #2  
Old Unix and Linux 09-21-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 17 April 2015, 5:55 PM EDT
Location: Saskatchewan
Posts: 20,487
Thanks: 875
Thanked 3,606 Times in 3,370 Posts
sh != ksh, run it with ksh -x. ksh supports arrays, sh does not, hence the error.
Sponsored Links
    #3  
Old Unix and Linux 09-21-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 17 April 2015, 5:55 PM EDT
Location: Saskatchewan
Posts: 20,487
Thanks: 875
Thanked 3,606 Times in 3,370 Posts
You're not actually using arrays for anything, though, you're just doing string splitting which can happen without using arrays at all.
Code:
STR="`cat file`"
echo $STR

But you don't need to load the entire file into a string at all. There's usually no reason to do that.


Code:
$ awk -v ORS=" " '{ sub(/[\\]/, ""); $1=$1 } 1; END{ printf("\n") }' inputfile

+DATA_DM01/pudwh/datafile/dw_billing_tts_1 +DATA_DM01/pudwh/datafile/dw_billing_tts_2 +DATA_DM01/pudwh/datafile/dw_billing_tts_3 +DATA_DM01/pudwh/datafile/dw_billing_tts_4 +DATA_DM01/pudwh/datafile/dw_billing_tts_5 +DATA_DM01/pudwh/datafile/dw_billing_tts_6 +DATA_DM01/pudwh/datafile/dw_billing_tts_7 +DATA_DM01/pudwh/datafile/dw_billing_tts_8 +DATA_DM01/pudwh/datafile/dw_billing_tts_9 +DATA_DM01/pudwh/datafile/dw_billing_tts_10 +DATA_DM01/pudwh/datafile/dw_billing_tts_11 +DATA_DM01/pudwh/datafile/dw_billing_tts_12 +DATA_DM01/pudwh/datafile/dw_billing_tts_13 +DATA_DM01/pudwh/datafile/dw_billing_tts_14 +DATA_DM01/pudwh/datafile/dw_billing_tts_15 +DATA_DM01/pudwh/datafile/dw_billing_tts_16 +DATA_DM01/pudwh/datafile/dw_billing_tts_17


Last edited by Corona688; 09-21-2012 at 03:39 PM..
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need A Script To List All Failed Log In Users oraQ UNIX for Advanced & Expert Users 3 02-13-2011 10:40 PM
AWK script getting failed unknown123 Shell Programming and Scripting 1 09-15-2009 02:18 AM
script for failed processes kumarabhi84 Shell Programming and Scripting 4 03-06-2009 04:57 AM
Need to start a script from the point where it failed. mac4rfree Shell Programming and Scripting 5 09-25-2008 02:01 AM
Rerunning a command in a script that failed? trey85stang Shell Programming and Scripting 5 07-18-2008 04:07 AM



All times are GMT -4. The time now is 06:59 AM.