Desperately Need Help On This Perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Desperately Need Help On This Perl script
# 8  
Old 10-04-2006
Quote:
Originally Posted by vino
Try this.
Code:
grep -r akamai * | sed -n -e "s+^\([^:]*:\).*\(http[^\"].*\)\".*+\1 \2+p"

Not tested tho.

this didn't work. I got one of those "Broken Pipe" error messages
Terrible
# 9  
Old 10-04-2006
Check out reborgs' solution.
# 10  
Old 10-04-2006
Quote:
Originally Posted by reborg
Any use to you?
Code:
grep -q akamai * | nawk -F'[<"]' '{print $1$3}'



this seems to work a little bit. but there are still lots of unwanted characters attached to the strings that i need to get rid off. the thing is, i guess you guys would have to actually see the output i'm trying to work on for u to see how u can help me.

i could probably do this in shell but they dont want shell programming, they want this done in perl.

i would greatly appreciate it if anyone would point me to a perl website that deals specifically and only with grabbing and filtering through strings. i'm not interested in anything else.
Terrible
# 11  
Old 10-04-2006
Quote:
Originally Posted by Terrible
nope it didn't work.
Quote:
Originally Posted by Terrible
this didn't work.
Quote:
Originally Posted by Terrible
this seems to work a little bit. but there are still lots of unwanted characters attached to the strings that i need to get rid off. the thing is, i guess you guys would have to actually see the output i'm trying to work on for u to see how u can help me.
It certainly wouldn't hurt. It'd also help to tell us how things are not working, a minor change may be all that's needed.
Quote:
i could probably do this in shell but they dont want shell programming, they want this done in perl.
Who is they?
Quote:
I would greatly appreciate it if anyone would point me to a perl website that deals specifically and only with grabbing and filtering through strings. i'm not interested in anything else.
Perl people tend to yell RTFM after having scattered their documentation in 9,000 different places, with ridiculous keywords/names only perl experts would ever guess; the web is not as useful a resource for perl as it could be, unfortunately. Try 'man perlretut'. If you don't have this manpage on your system, I've uploaded it here.
# 12  
Old 10-04-2006
Try this
Code:
grep -r akamai *  | perl -ane '$F[2] =~ s/^.*"(.*)"/$1/;print "$F[0] $F[2]"'

If this doesn't work show your result of grep -r akamai *
# 13  
Old 10-04-2006
below is a better example of the outputs i have to filter through.


./NLT/sports/index.html: var myFlashObject = new FlashObject("http://a740.g.akamai.net/f/740/606/1d/image.pathfinder.com/TFK/media/shockflash/DSWMedia/feature_v1d.swf?bg_color=6600FF&head_text_1=Remembering+Steve+Irwin&head_size_1=26&head_lcnt_1=3&hea d_text_2=&head_size_2=0&head_lcnt_2=0&head_text_3=&head_size_3=0&head_lcnt_3=0&deck_text=The+adventu rous+�crocodile+hunter�+and+conservation+hero+dies+after+a+stingray+attack&deck_size=14&xref_link=/TFK/news/story/0,6260,1531665,00.html", "TFK News cover", "270", "145",5, "#6600FF");


and the above is only from one file. so imagine when i do a grep -r * on a directory full with files that contain strings that are similar. the list is very long and pretty much impossible (at least i think) to script.

so basically, what i need from that abysmal output is the file name which the output was found in and that would be == /NLT/sports/index.html and I also need the http string that contains "akamai.net". everything else needs to be filtered out.
Terrible
# 14  
Old 10-04-2006
try this
Code:
grep -r akamai * | perl -ne '$_=~ s/^([^:]*).*(http.*akamai[^"]*).*$/\1: \2/; print $_'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

Excuting perl script from within a perl script with variables.

Not sure what I am doing wrong here, but I can print the list with no issue. Just a blank screen with the 'do'. #!/usr/bin/perl open FILE, "upslist.txt"; while ($line=<FILE>){ if ($line=~/^(.*?),(.*?)$/){ #print "ups:$1 string:$2\n"; do 'check_snmp_mgeups-0.1.pl -H $1 -C $2'; } ... (1 Reply)
Discussion started by: mrlayance
1 Replies

3. Shell Programming and Scripting

Perl : embedding java script with cgi perl script

Hi All, I am aware that html tags can be embedded in cgi script as below.. In the same way is it possible to embed the below javascript in perl cgi script ?? print("<form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">"); print("<input type = "text"... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Shell Programming and Scripting

executing perl script from another perl script : NOT WORKING

Hi Folks, I have 2 perl scripts and I need to execute 2nd perl script from the 1st perl script in WINDOWS. In the 1st perl script that I had, I am calling the 2nd script main.pl =========== print "This is my main script\n"; `perl C:\\Users\\sripathg\\Desktop\\scripts\\hi.pl`; ... (3 Replies)
Discussion started by: giridhar276
3 Replies

5. Shell Programming and Scripting

Expect Scripting Loop Argument Desperately Needed!

I am trying to create an Expect script that does the following: 1) Telnets to an IP address and logs in with user ID and Password 2) Issue a CLI command to the server that will output data of which I am particularly interested in a DS1 clock 'Slips' value. I want to be able to keep issuing... (0 Replies)
Discussion started by: dwightlaidler
0 Replies

6. Shell Programming and Scripting

calling a perl script with arguments from a parent perl script

I am trying to run a perl script which needs input arguments from a parent perl script, but doesn't seem to work. Appreciate your help in this regard. From parent.pl $input1=123; $input2=abc; I tried calling it with system("/usr/bin/perl child.pl $input1 $input2"); and `perl... (1 Reply)
Discussion started by: grajp002
1 Replies

7. UNIX for Dummies Questions & Answers

UNIX advice needed desperately :/

Firstly I do need to state that I am turning here as a last resort. Im in my first year of a Computer Networking and technical support course, and as a first year I must complete a Introductory Unix/Linux class. I have been doing well in the course so far however I have been stumped on the final... (1 Reply)
Discussion started by: setaylor5
1 Replies

8. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

9. Shell Programming and Scripting

Help needed desperately

Hello Folks, i have written a script to nullify the log files in my dev environment but the log files are not getting nullified.Please find below my script and also thank you all in advance for your help. find /app -size +100000 -xdev -exec du -k {} \; 2>/dev/null | sort -nr |ls -1dF ... (2 Replies)
Discussion started by: Rayzone
2 Replies

10. Shell Programming and Scripting

Help needed desperately......

Hi guys, I want to execute an SQL script based on a condition.... I am writing a sample requirement... num = {some value} if(num == 0) then cat>> test.sql <<FIN select * from table_a FIN else cat>> test.sql << FIN select * from table_b FIN fi This is what i... (3 Replies)
Discussion started by: Payal Sharma
3 Replies
Login or Register to Ask a Question