Sponsored Content
Top Forums Shell Programming and Scripting RegExp negative match not working Post 302086092 by pondlife on Tuesday 22nd of August 2006 06:26:09 AM
Old 08-22-2006
Some time ago...

Hi Umen,

I did something similar sometime ago in perl here's the final code that takes my array and does the replace throughout the opened file:

Code:
foreach my $key (keys %enabled_yn) {
 $enabled_yn{$key} =~ chomp;
 $enabled_yn{$key} =~ s/Y/\<b\>\<font color=\"yellow\"\>Y\<\/font\>\<\/b\>/;
 $enabled_yn{$key} =~ s/ALL/\<b\>\<font color=\"yellow\"\>ALL\<\/font\>\<\/b\>/;
}


open (ZMIO, "/opt/apache/cgi-bin/html_templates/zmio.htp") or "Couldn't open file $!";
read (ZMIO,$html,-s "/opt/apache/cgi-bin/html_templates/zmio.htp") or "Couldn't open file $!";

      $html =~ s/%(\w+)%/$enabled_yn{$1}/g;

print $html;

The penultimate line starting $html is where the regexp is taking place.

HTH,

Cheers,
pondlife.

Last edited by blowtorch; 08-22-2006 at 07:35 AM.. Reason: removed link
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

print the line immediately after a regexp; but regexp is a sentence

Good Day, Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp. sed -n '/regexp/{n;p;}' filename What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies

2. Shell Programming and Scripting

Regexp to match all characters including "?"

Hi everyone, I'm almost tearing my hairs to find a valid regexp which will match EVERY character in a string, including the question mark! Specifically I need to match a string which contains the word (example) "stringtobematched" at the end of it. Everyone would suggest this: ... (4 Replies)
Discussion started by: lycaon
4 Replies

3. Shell Programming and Scripting

perl regexp: no match across newlines

Hi. Here's a tricky one (at least to me): I have a file named theFile.txt (UTF-8) that contains the following: a b cWhen I execute perl -pe 's|a.*c|d|sg' theFile.txtin bash 3.2 on MAC OS X 10.6, I get no match, i.e. the result is a b cagain. Any clues why? (2 Replies)
Discussion started by: BatManWSL
2 Replies

4. UNIX for Dummies Questions & Answers

regexp: match string that contains list of chars

Hi, I'm curious about how to do a very simple thing with regular expressions that I'm unable to figure out. If I want to find out if a string contains 'a' AND 'b' AND 'c' it can be very easily done with grep: echo $STRING|grep a|grep b|grep c but, how would you do that in a single... (9 Replies)
Discussion started by: jimcanoa
9 Replies

5. UNIX for Dummies Questions & Answers

Grep Regexp not working correctly

Consider the following code: grep -o -e '^STEAM_::\d+$' workfile3.tmp A sample format of a valid string for the regexp would be: STEAM_0:1:12345678 Here is an example line from the workfile3.tmp file: 465:L 01/02/2012 - 00:05:33: "Spartan1-1-7<8><STEAM_0:1:47539638><>" connected No... (2 Replies)
Discussion started by: spinner0205
2 Replies

6. Shell Programming and Scripting

Question on TCL regexp and match

Hello everyone, I'm new in tcl scripting. I'm currently studying a tcl script and came across this line: regexp {(\d+)(\S?)} $opts match opt swi According to my understanding, this line means to search in the opts variable for one or more digit, followed by a non-whitespace character... (2 Replies)
Discussion started by: mar85
2 Replies

7. Shell Programming and Scripting

Match working for some but not all

I am not sure why the script below seems to pull the correct values for most, but not all. Basically what is supposed to result is the $1 value in genes.txt is matched to the $3 value in RefSeqGene.txt and the value in 6 field is copied. In the output below that is the case most of the time but... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

9. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
upsstats.cgi(8) 					      Network UPS Tools (NUT)						   upsstats.cgi(8)

NAME
upsstats.cgi - Web-based UPS status viewer SYNOPSIS
upsstats.cgi NOTE
As a CGI program, this should be invoked through your web server. If you run it from the command line, it will either complain about unau- thorized access or spew a bunch of HTML at you. DESCRIPTION
upsstats.cgi uses template files to build web pages containing status information from UPS hardware. It can repeat sections of those tem- plate files to monitor several UPSes simultaneously, or focus on a single UPS. These templates can also include references to upsimage.cgi(8) for graphical displays of battery charge levels, voltage readings, and the UPS load. ACCESS CONTROL
upsstats will only talk to upsd(8) servers that have been defined in your hosts.conf(5). If it complains that "Access to that host is not authorized", check that file first. TEMPLATES
The web page that is displayed is actually a template containing commands to upsstats which are replaced by status information. The default file used for the overview is upsstats.html. When monitoring a single UPS, the file displayed is upsstats-single.html. The format of these files, including the possible commands, is documented in upsstats.html(5). FILES
hosts.conf(5) upsstats.html(5) SEE ALSO
upsimage.cgi(8) Internet resources: The NUT (Network UPS Tools) home page: http://www.exploits.org/nut/ NUT mailing list archives and information: http://lists.exploits.org/ Mon Sep 2 2002 upsstats.cgi(8)
All times are GMT -4. The time now is 03:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy