Error with script interaction


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error with script interaction
# 1  
Old 08-11-2009
Error with script interaction

Hi I have a script which is coming up with errors when I iterate over a list of database names. When I print out the values it shows a title & underline...if I then attach "hi" to the print out I get :
hi
TBS_SVC_NAME hi
------------------------------ hi
bkahepa hi
hi

Code:
echo "select distinct tbstat.tbs_svc_name
          from tbstat, srvc 
          where  tbstat.tbs_svc_name = srvc.svc_name 
          and srvc.svc_app_name = 'c3' and srvc.svc_app_type = 'L' and tbstat.tbs_svc_name = 'bkahepa';" | 
D:/user-applications/oracle/ora92/bin/sqlplus.exe -s $HKLOGIN/${HKPWD}@$HKSVC | while read line
do
if [[ line = TBS_SVC_NAME% ]] then ""
else
echo "$line hi"
fi
done

This is my test script where the only difference is the if statement & instead of echoing I pass $line as a parameter...could it be that the heading etc are passed as parameter values? if so how can I prevent this? Thanks for any help.

Edit: The if statement was a bad attempt by me at excluding the heading from being processed.

Mike
# 2  
Old 08-11-2009
What an odd mix of DOS and shell! What are you using exactly?

By "title and underline", you mean the heading? Why not switch it off (by doing the usual "set heading off feedback off pagesize 0, etc...)

What is the error?
# 3  
Old 08-11-2009
Hi,

I'm using korn shell. Where would that info (set heading off) go in my code?

The error is abnormal exit which is based off:
Code:
trap "stty sane;echo '\n\n   *** Abnormal exit ***';exit" 1 2 3 4 5 6 7 8 9 15

That is after taking ages (~30 mins?) frozen...I can't remember if I had pressed ctrl + c before that though

Edit: When I run the program printing out text with echo "$line collecting..." it gets displayed like " collecting" so I assume it's reading in that line above the heading when it shouldn't as I only want it to pass the data from the table

By title & underline I mean everything except the bkahepa line

Last edited by Dird; 08-11-2009 at 06:44 AM..
# 4  
Old 08-11-2009
Perhaps something like this
(sorry I don't have access to Oracle, so I can't test the exact scenario)

Code:
cat << ! | D:/user-applications/oracle/ora92/bin/sqlplus.exe -s $HKLOGIN/${HKPWD}@$HKSVC | while read line; do echo $line; done
set heading off
set feedback off
set pagesize 0
set serveroutput on
select distinct tbstat.tbs_svc_name
          from tbstat, srvc
          where  tbstat.tbs_svc_name = srvc.svc_name
          and srvc.svc_app_name = 'c3' and srvc.svc_app_type = 'L' and tbstat.tbs_svc_name = 'bkahepa';
!

Or, maybe this is a bit nicer to look at:
Code:
{
cat << !
set heading off
set feedback off
set pagesize 0
set serveroutput on
select distinct tbstat.tbs_svc_name
          from tbstat, srvc
          where  tbstat.tbs_svc_name = srvc.svc_name
          and srvc.svc_app_name = 'c3' and srvc.svc_app_type = 'L' and tbstat.tbs_svc_name = 'bkahepa';
!
} | D:/user-applications/oracle/ora92/bin/sqlplus.exe -s $HKLOGIN/${HKPWD}@$HKSVC | while read line; do
  echo $line
done

I don't remember if it's neccessary to add a
Code:
/

before the closing "!" i.e.
Code:
/
!


Last edited by Scott; 08-11-2009 at 07:12 AM.. Reason: Just remembered the / is only needed with PL/SQL!
# 5  
Old 08-11-2009
Hi Scott,

Thanks so much it works perfectly. I'll try the 2nd idea after this is done running as that would allow for multiple lines in the do while I'm guessing whereas I tried doing 3 lines (2 echos and the actual work) but it had some EOF when expecting done error. With just the file interaction the first works perfectly though.

Thanks again

---------- Post updated at 06:39 AM ---------- Previous update was at 04:58 AM ----------

Oh If I wanted to call a procedure after looping without the need to reconnect would I just add to the pipe like below?:
Code:
cat << !
set heading off
set feedback off
set pagesize 0
set serveroutput on
select distinct tbstat.tbs_svc_name
          from tbstat, srvc
          where  tbstat.tbs_svc_name = srvc.svc_name
          and srvc.svc_app_name = 'c3' and srvc.svc_app_type = 'L';
!
} | D:/user-applications/oracle/ora92/bin/sqlplus.exe -s $HKLOGIN/${HKPWD}@$HKSVC | while read line; do
echo "$line collecting..."
./hkstats.ksh all $line
echo "$line completed..."
done | begin EMAIL_PROCEDURE; end; /

# 6  
Old 08-11-2009
Hi.

Looks like you're trying to use PL/SQL there?

That won't work. What exactly does EMAIL_PROCEDURE do?

I mean, if you want to mail the results then you could say

Code:
done| mailx -s "some subject" someone@somewhere.com

or..
Code:
done | uuencode somename.txt | mailx -s "some subject" someone@somewhere.com

# 7  
Old 08-11-2009
Hi Scott,

I wish to call a stored procedure located on the database I connect to through SQLPlus.

Quote:
Originally Posted by scottn
Hi.

Looks like you're trying to use PL/SQL there?

That won't work. What exactly does EMAIL_PROCEDURE do?

I mean, if you want to mail the results then you could say

Code:
done| mailx -s "some subject" someone@somewhere.com

or..
Code:
done | uuencode somename.txt | mailx -s "some subject" someone@somewhere.com

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Avoid interaction into script

Sorry for my english! I'm using Debian squeeze and for an assignement, i have create 2 virtual pdf cups printers. Both are working very well. To test the different administion command; i try to disable one of the printer and move his queue file to the second one. I'm able to do it easily. ... (4 Replies)
Discussion started by: lyapma
4 Replies

2. UNIX for Advanced & Expert Users

PAM and vsftp interaction

If I use to PAM to validate a vsftp user using a remote service to do the validation and the user does not exist on the system locally, then what becomes the home directory for the user logging in via vsftp? Assuming that chroot_user_list is enable to limit all users to their home directory. (0 Replies)
Discussion started by: ChrisC
0 Replies

3. Shell Programming and Scripting

Expect help/interaction with switch..

Hi All, I have been trying to get an Expect program to communicate with a Remote Power Switch which will eventually log in, and then turn on/off certain outlets. For some reason, I can't get through the log in procedure with this Switch. When you first spawn the telnet, you get the Switch... (1 Reply)
Discussion started by: mrjgs70
1 Replies

4. Shell Programming and Scripting

textbox and user interaction

I'm wanting to get user interaction...textbox or checkboxes would be great. I want to allow someone to enter data into textbox. (this is the time I want to grab a photo from) Then I want to be able to check the different sizes I want for the image. Say 4 options. Is this possible using the... (0 Replies)
Discussion started by: mainegate
0 Replies

5. Programming

Needed help in a ruby script with user interaction involved!

Hi all, I am struck at this point and needed some help in ruby I wanted to write a script that accepts the no of VNICs the user wants to create and then ask for the name of each Vnic he wants then use these names to create the corresponding Vnics Eg: suppose that there are 2 Vnics to be... (0 Replies)
Discussion started by: wrapster
0 Replies

6. Shell Programming and Scripting

ksh and awk interaction

in a ksh script, i want to process some string variables using awk, and then i want to go on using this variables in the same ksh (out of awk lines) can anybody send me a very simple example about this? (0 Replies)
Discussion started by: gfhgfnhhn
0 Replies

7. HP-UX

Boot interaction

Hi All, I am the new boy on the Block with HP-UX. To get to the point, I have a Hp-ux (C200) workstation running on Hp-ux 11.x Operating System. A week ago when practicing on file access permission, I have set the permission on a directory (perhaps a file I am not sure) to 0544 and did... (19 Replies)
Discussion started by: mhossien
19 Replies

8. Programming

client server interaction? anyone know

hi there, i need help :( im trying to produce a program that would do the following, but i dont know were to begin, any help/guide lines, please im need help asap, One program is the main program, which fork/execs one referee process and three x,y,z processes repectvley. It then waits until... (0 Replies)
Discussion started by: zmanultra
0 Replies

9. Shell Programming and Scripting

bash and Perl interaction questions

hi. im working in bash and am trying to create a Perl daemon that controls bashs behavior. this is actually in preparation for a later project ill be working on. basically, im looking for a way to have the Perl daemon tell bash what to do. i already have a small daemon that simply prints... (2 Replies)
Discussion started by: deryk
2 Replies

10. UNIX for Dummies Questions & Answers

Help in setting up password without Interaction.

Can anybody tell me how can I create an account without having to enter the password after editing the vipw file. I mean the system should automatically take care of the password encryption in the shadow file and I don't to enter the password again and the Account should be ready to go. ... (3 Replies)
Discussion started by: syedifti
3 Replies
Login or Register to Ask a Question

Featured Tech Videos