Can anyone find the mistake in this script file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can anyone find the mistake in this script file
# 8  
Old 10-12-2011
Quote:
Originally Posted by rkrish
Again the same error mentioned above...no change in error description..:-(

---------- Post updated at 04:05 AM ---------- Previous update was at 03:57 AM ----------
what must be $1 and $2 ?
and what is your goal with this?
Code:
a = select   ACK_PARTY_NAME,bus_event_seq_nbr  from bus_event where  ack_party_name like 'MOVE_USAGE_DAEMON%'  and bus_event_seq_nbr='3969094'

this is invalid expression if you want to assign value to any variable.
you must use this way with double quotes
Code:
a=" select   ACK_PARTY_NAME,bus_event_seq_nbr  from bus_event where  ack_party_name like 'MOVE_USAGE_DAEMON%'  and bus_event_seq_nbr='3969094'"

# 9  
Old 10-12-2011
Hi,
I ran the script but unfortunately the o/p is not correct..instead of the column values to be passed as arguments...it is passing the column names..
o/p from sql :
Code:
 
    ACK_PARTY_NAME               BUS_EVENT_SEQ_NBR 
  MOVE_USAGE_DAEMON1                3969413

ran the script:
Code:
#!/bin/ksh
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969413';
EOF`
set -- $(echo $a | sed 's,[aA-zZ]*,,1')
echo Run -i $1 -e $2


and the o/p is :
Code:
Run -i BUS_EVENT_SEQ_NBR -e ----------------------------------------


required o/p is :
Code:
Run -i 1 -e 3969413

---------- Post updated at 04:27 AM ---------- Previous update was at 04:23 AM ----------

Quote:
Originally Posted by ygemici
what must be $1 and $2 ?
and what is your goal with this?
Code:
a = select   ACK_PARTY_NAME,bus_event_seq_nbr  from bus_event where  ack_party_name like 'MOVE_USAGE_DAEMON%'  and bus_event_seq_nbr='3969094'

this is invalid expression if you want to assign value to any variable.
you must use this way with double quotes
Code:
a=" select   ACK_PARTY_NAME,bus_event_seq_nbr  from bus_event where  ack_party_name like 'MOVE_USAGE_DAEMON%'  and bus_event_seq_nbr='3969094'"


The output values of the above select query will be like:
Move_Usage_Daemon1 , 3969413


and I should pass 1(digit appended at the end of frst field) and other variable to command.
It will be like:

Run -i 1 -e 3969413

Last edited by Franklin52; 10-12-2011 at 06:34 AM.. Reason: Please use code tags, thank you
# 10  
Old 10-12-2011
Quote:
Originally Posted by rkrish
Hi,
I ran the script but unfortunately the o/p is not correct..instead of the column values to be passed as arguments...it is passing the column names..
o/p from sql :
Code:
 
    ACK_PARTY_NAME               BUS_EVENT_SEQ_NBR 
  MOVE_USAGE_DAEMON1                3969413

ran the script:
Code:
#!/bin/ksh
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969413';
EOF`
set -- $(echo $a | sed 's,[aA-zZ]*,,1')
echo Run -i $1 -e $2


and the o/p is :
Code:
Run -i BUS_EVENT_SEQ_NBR -e ----------------------------------------


required o/p is :
Code:
Run -i 1 -e 3969413

---------- Post updated at 04:27 AM ---------- Previous update was at 04:23 AM ----------




The output values of the above select query will be like:
Move_Usage_Daemon1 , 3969413


and I should pass 1(digit appended at the end of frst field) and other variable to command.
It will be like:

Run -i 1 -e 3969413
can you write the output of this?
Code:
.............
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969413';
EOF`
echo "$a"

# 11  
Old 10-12-2011
Quote:
Originally Posted by ygemici
can you write the output of this?
Code:
.............
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969413';
EOF`
echo "$a"

yeah I ran it..

O/p is :
ACK_PARTY_NAME BUS_EVENT_SEQ_NBR
---------------------------------------- -----------------
MOVE_USAGE_DAEMON1 3969413

---------- Post updated at 05:51 AM ---------- Previous update was at 05:35 AM ----------

Quote:
Originally Posted by ygemici
can you write the output of this?
Code:
.............
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969413';
EOF`
echo "$a"


The query result is displayed
# 12  
Old 10-12-2011
Quote:
Originally Posted by rkrish
yeah I ran it..

O/p is :
ACK_PARTY_NAME BUS_EVENT_SEQ_NBR
---------------------------------------- -----------------
MOVE_USAGE_DAEMON1 3969413

---------- Post updated at 05:51 AM ---------- Previous update was at 05:35 AM ----------




The query result is displayed
try this instead of your sed
Code:
set -- $(echo $a|sed 's/.*\([^ ]1*\) \([^ ]*\)/\1 \2/')

# 13  
Old 10-12-2011
Quote:
Originally Posted by ygemici
try this instead of your sed
Code:
set -- $(echo $a|sed 's/.*\([^ ]1*\) \([^ ]*\)/\1 \2/')

Got the same output

script I ran is :
Code:
#!/bin/ksh
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969413';
EOF`
set -- $(echo $a|sed 's/.*\([^ ]1*\) \([^ ]*\)/\1 \2/')
echo "$a"

Smilie

Last edited by Franklin52; 10-12-2011 at 09:55 AM.. Reason: Please use code tags, thank you
# 14  
Old 10-12-2011
Quote:
Originally Posted by rkrish
Got the same output

script I ran is :
Code:
#!/bin/ksh
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969413';
EOF`
set -- $(echo $a|sed 's/.*\([^ ]1*\) \([^ ]*\)/\1 \2/')
echo "$a"

Smilie
did you try this? what is the output? is same?
Code:
#!/bin/ksh
db_user=`echo $DB_USER_NAME`
db_pwd=`echo $DB_PASSWORD`
db_sid=`echo $TWO_TASK`
a=`sqlplus -s $db_user/$db_pwd@$db_sid << EOF
select   ACK_PARTY_NAME,bus_event_seq_nbr  from bus_event where  ack_party_name like 'MOVE_USAGE_DAEMON%'  and bus_event_seq_nbr='3969094';
EOF`
set -- $(echo $a|sed 's/.*\([^ ]1*\) \([^ ]*\)/\1 \2/')
echo Run -i $1 -e $2

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Archive script spot a mistake?

#!/bin/bash source=/to_be_archived dest=/archived echo "is this archive for an audio tar press (t) or an audio directory press (d)" read option case $option in d) cd "$source" echo "please specify full path to directory you want to be... (6 Replies)
Discussion started by: robertkwild
6 Replies

2. Shell Programming and Scripting

Perl script to read string from file#1 and find/replace in file#2

Hello Forum. I have a file called abc.sed with the following commands; s/1/one/g s/2/two/g ... I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat sed -f abc.sed abc.dat >... (10 Replies)
Discussion started by: pchang
10 Replies

3. UNIX for Dummies Questions & Answers

Can anyone help me to spot my mistake?

Hi there can anyone help me to spot my mistake and please explain why it appears My code : #!/usr/bin/gawk -f BEGIN { bytes =0} { temp=$(grep "datafeed\.php" | cut -d" " -f8) bytes += temp} END { printf "Number of bytes: %d\n", bytes } when I am running ./q411 an411 an411: ... (6 Replies)
Discussion started by: FUTURE_EINSTEIN
6 Replies

4. Shell Programming and Scripting

Do not find the mistake in a small routine!!!

Have a textfile (regular updated) with informations about datafiles . Each line is describing a datafile. Now I am trying to delete several specific lines in this textfile, which are defined before in a kind of removal list. Can not find the mistake I have done in the script because in the... (5 Replies)
Discussion started by: jurgen
5 Replies

5. UNIX for Dummies Questions & Answers

Probably some stupid mistake...

Hi everyone ! I have a file wich look like this : >Sis01 > Sis02 ... >Sis44 I want to separe each paragraphe in a different file, so I decide to use the "FOR" loop + sed. for f in {01..44} do (5 Replies)
Discussion started by: sluvah
5 Replies

6. Shell Programming and Scripting

Is there any mistake in this code:

cat $1 | sort -n | uniq | $1 in other words, I sort the content of the file and put the ouput in the same file, is there any mistakes in this cshell code ??? (4 Replies)
Discussion started by: Takeeshe
4 Replies

7. Shell Programming and Scripting

Removing rows based on a different file (ignore my earlier post - there was a mistake).

Sorry I made a mistake in my last post (output is suppose to be the opposite). Here is a revised post. Hi, I am not sure if this has already been asked (I tried the search but the search was too broad). Basically I want to remove rows based on another file. So file1 looks like this (tab... (3 Replies)
Discussion started by: kylle345
3 Replies

8. Shell Programming and Scripting

Can't find the mistake in sed expression

Hi there, Can anyone help me find the correct expression for sed. I want to repace iface eth0 inet wathever with iface eth0 inet static Thanks for your help Santiago (5 Replies)
Discussion started by: chebarbudo
5 Replies

9. AIX

Did a Mistake with HACMP

Hi, I needed space on a FS, and when I've added the space on the filesystem, I did it trough the regular smitty fs inteface and not with smitty cl_lvm. Can someone help me to repair the situat before a faileover happen ? Thanks for your help,:mad: (13 Replies)
Discussion started by: azzed27
13 Replies

10. Shell Programming and Scripting

how to find Script file location inside script

I have to find out the file system location of the script file inside script. for example a script "abc.sh" placed anywhere in the file system when executed shold tell by itself the location of it. example #pwd / #./abc this is / #cd /root #./abc this is /root #cd / #/root/abc this... (10 Replies)
Discussion started by: asami
10 Replies
Login or Register to Ask a Question