|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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_17While 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
|
|||
|
|||
|
sh != ksh, run it with ksh -x. ksh supports arrays, sh does not, hence the error.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
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_17Last edited by Corona688; 09-21-2012 at 03:39 PM.. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
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 |
|
|