dynamic output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting dynamic output
# 8  
Old 04-06-2010
Thanks a lot Tyler.. Appreciate your qucik reply ... as i have zero knowledge on Perl... hence i would like to understand how actually how the script is working.. Thanks again..
# 9  
Old 04-06-2010
Quote:
Originally Posted by nitinrp1
... as i have zero knowledge on Perl... hence i would like to understand how actually how the script is working...
In the simplest terms, the script searches for a line that matches the regular expression pattern and prints a chunk from the pattern.

If you have zero knowledge of Perl, then you are lucky as nowadays there's a huge wealth of resources on the Internet and books etc. that can help you. Google is your friend here. Books by O'Reilly are pretty good.

I can tell you what that regex does, but it would be better if you have at least a rudimentary knowledge of terms like "metacharacters", "backreferences", "character-classes", "repetition quantifiers" before that. You may want to check out the book by Jeffrey Friedl, which is probably one of the best on regexes.

HTH,
tyler_durden
# 10  
Old 04-09-2010
Thanks Tyler...

Assume i have the input file as below

Code:
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qrylog
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username in ('tst1','xxx_yyy_drv_01')

Now i need the ouptut as in , can this be done using perl ... apprceiate help over here

Last edited by Franklin52; 04-09-2010 at 03:36 AM.. Reason: Please use code tags!
# 11  
Old 04-09-2010
Quote:
Originally Posted by nitinrp1
...
Assume i have the input file as below

Code:
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qrylog
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username in ('tst1','xxx_yyy_drv_01')

Now i need the ouptut as in , can this be done using perl ...
Yes, it can be done using Perl -

Code:
$
$
$ cat file6.sql
SELECT elapsedtime ,StartTime,QueryText
FROM     dbc.qrylog
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username in ('tst1','xxx_yyy_drv_01')
$
$
$ perl -lne '/^(\s*\w+){2}\s*(=|in)[\s(]*.*$/ && print $2' file6.sql
in
$
$

tyler_durden
# 12  
Old 04-09-2010
Originally Posted by nitinrp1
...
Assume i have the input file as below



Code:
SEL elapsedtime ,StartTime,QueryText
FROM dbc.qrylog
WHERE StartTime >= '2010-03-24 20:10:08'
AND username in ('tst1','xxx_yyy_drv_01')
and user = ('abc_aaa')

For the above code if i run the perl script given by its gives out put as in and =

the requried output should be only in

thanks again..
pls help
# 13  
Old 04-09-2010
Quote:
Originally Posted by nitinrp1
...
Code:
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qrylog
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username in ('tst1','xxx_yyy_drv_01') 
and user = ('abc_aaa')

For the above code if i run the perl script given by its gives out put as in and =
It returns output "in" because "in" is present in the query. Check that last but one line of your query.

It returns output "=" because "=" is present in the query. Check the last line of your query.

Quote:
...
the requried output should be only in
...
(a) Why should it be "in" ?
(b) Why should it not be "=" ?

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk : dynamic output flatfile filename

Hello, I'm using the awk command to insert empty columns on a tab delimited flatfile - which works fine - => But I'm not able to manage dynamicaly the filename of the awk output based on the source flatfile filename I have 3 source flatfile: flatfile_Jan-2016.csv flatfile_Feb-2016.csv... (3 Replies)
Discussion started by: Tipiak
3 Replies

2. Shell Programming and Scripting

Assign output to dynamic variable

Hi Folks, I am trying to assign a value from the command to a dynamic variable. But I am not getting the desired output.. I am sure something is wrong so i need experts advise. There will be multiple files like /var/tmp/server_1, /var/tmp/server_2, /var/tmp/server_3, having different server... (6 Replies)
Discussion started by: ganga.dharan
6 Replies

3. Shell Programming and Scripting

Dynamic case creation based on output list from a command

I am attempting to create a script that would allow me to list all the instances associated with a DB2 and then prompt the user to choose which one to issue the db2profile command against. I use the db2 command db2ilist to get a list of the instances for a particular server, but the number of... (7 Replies)
Discussion started by: slatoms
7 Replies

4. Red Hat

Dynamic case creation based on output list from a command

I am attempting to create a script that would allow me to list all the instances associated with a DB2 and then prompt the user to choose which one to issue the db2profile command against. I use the db2 command db2ilist to get a list of the instances for a particular server, but the number of... (1 Reply)
Discussion started by: slatoms
1 Replies

5. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

6. Shell Programming and Scripting

Parsing dynamic data from a command output

Hi people, I am writing a korn shell script, and one of the command gives an output something like below: release.label.2010.03.02 objects: /project/path/to/some/file_name.ksh /project/path/another/file_name01.dat I have to retrieve the file paths one by one & use them as... (9 Replies)
Discussion started by: kiwin1000
9 Replies

7. UNIX for Advanced & Expert Users

Sql dynamic table / dynamic inserts

I have a file that reads File (X.txt) Contents of record 1: rdrDESTINATION_ADDRESS (String) "91 971502573813" rdrDESTINATION_IMSI (String) "000000000000000" rdrORIGINATING_ADDRESS (String) "d0 movies" rdrORIGINATING_IMSI (String) "000000000000000" rdrTRAFFIC_EVENT_TIME... (0 Replies)
Discussion started by: magedfawzy
0 Replies

8. Programming

dynamic linking

Hi, Could any one tell me solution for this. i have a library in my /usr/lib and latest in /myhome/lib/ (thay differ functionality symbols my application uses symbols from latest lib). when compile and link my application , every thing goes fine but when running the application ld... (4 Replies)
Discussion started by: Raom
4 Replies

9. Linux

how to dynamic DNS

hi i am using fedora core 5 and i already configured the dhcp server and the dns server but i want to configure dynamic dns to update the dns automatiklly thank you in advance (1 Reply)
Discussion started by: bondoq
1 Replies

10. OS X (Apple)

Dynamic DNS

I have a need to regularly add all macs in our domain to dns. Ideally it would work like Wintel machines. Transparently and automatically. What are the tools, scripts, roadblocks to doing so? I'm not talking about DynDNS type of service here. This is the internal dns for where I work. (0 Replies)
Discussion started by: [MA]Flying_Meat
0 Replies
Login or Register to Ask a Question