Sponsored Content
Full Discussion: Perl command error...
Top Forums Shell Programming and Scripting Perl command error... Post 302415551 by durden_tyler on Thursday 22nd of April 2010 10:33:19 PM
Old 04-22-2010
Quote:
Originally Posted by bigben1220
...

Imtrying to run:

[code]
#!/usr/bin/perl

perl -nle 'print if /\var\/log/' /etc/syslog.conf[code]But I keep getting error: Do you need to predeclare -nle.Im trying to create a script that read the contents of /etc/syslog.conf and print out every line that contains /var/log.
Run the Perl one-liner on the *nix command prompt.
My file "f4" is equivalent to your "/etc/syslog.conf" in the testcase below -

Code:
$ 
$ cat f4
first line
/var/log in this line
third line
and this line also has /var/log
fifth line
sixth line
and /var/log embedded in here too
$ 
$ perl -nle 'print if /\/var\/log/' f4
/var/log in this line
and this line also has /var/log
and /var/log embedded in here too
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Script Error with find command

Guys, I need to find all the files ending with either dmp or dmp.Z. This command is giving me error. @files =`find $path \(-name "*.dmp" -o -name "*.dmp.Z"\) -mtime +30`; sh: 0403-057 Syntax error at line 1 : `(' is not expected. Thanks in advance (4 Replies)
Discussion started by: MKNENI
4 Replies

2. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

3. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

4. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

5. Shell Programming and Scripting

Convert Sed command to perl command

Hello, Can any perl experts help me convert my sed string to perl. I am unsuccessful with this. I have to remove this string from html files OAS_AD('Top'); I have come up with this. However the requirement is in perl. for find in $(find . -type f -name "file1.html") ; do cat $find |... (2 Replies)
Discussion started by: abacus
2 Replies

6. Shell Programming and Scripting

Perl & Sed command -- Out of Memory Error

Experts, We used to receive our source files with '~^' as row delimiter. This file contains 2500K records and two of the columns having value in HTML formats within the file. While running the below commands against the file, we are encountering out of memory, could you please help to... (3 Replies)
Discussion started by: srivijay81
3 Replies

7. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

8. Shell Programming and Scripting

Perl command error

In the attached file I get this error. Thank you :). C:\cygwin\home\cmccabe\windows_annovar.sh: line 117: perl: command not found (17 Replies)
Discussion started by: cmccabe
17 Replies

9. Shell Programming and Scripting

Perl error in batch command but works one at a time

In the below perl executes if one file is processed perfect. However, when multiple files are processed in batch which is preferred I get the below error that I can not seem to fix it as the '' necessary for the command to execute, but seem to only work for one -arg option. Thank you :). ... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. AIX

Perl error : perl: warning: Setting locale failed.

This's my problem perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = "en_US.UTF-8", LC__FASTMSG = "true", LC_MESSAGES = "", LC_CTYPE = "en_US.UTF-8", LC_TYPE = "en_US.UTF-8", LANG = "EN_US"... (1 Reply)
Discussion started by: bobochacha29
1 Replies
SNMPTRAPFMT(8)						      System Manager's Manual						    SNMPTRAPFMT(8)

NAME
snmptrapfmt - Receive and log SNMP trap messages from a trap handler. SYNOPSIS
snmptrapfmt [-d num] [-D] [-f cfgfile] DESCRIPTION
Snmptrapfmt receives SNMP trap data through a local pipe. The trap data is written to this pipe by a SNMP trap handler which is called by snmptrapd (configuration is done in /etc/snmp/snmptrapd.conf) during the installation if this package. Snmptrapfmt formats the received trap data according to the specifications in the configuration file /etc/snmp/snmptrapfmt.conf (see this file for the syntax). The output of the snmptrapfmt application may be written to a log file or forwarded to the syslog daemon. The option -d 1 should be specified to enable tracing. Trace information is then written to the file /var/tmp/snmptrapfmt.trc. If the option -f cfgfile is given, the output of the daemon is configured via the mentioned configuration file. If this option is not spec- ified, a default output format is used. If the option -D is given, the the program will daemonize into the background. The syntax of the configuration file is explained in /etc/snmp/snmptrapfmt.conf ! FILES
/etc/init.d/snmptrapfmt is the start/stop script. /etc/snmp/snmptrapfmt.conf is the configuration file. /var/run/snmptrapfmt.pid is the PID file. /etc/snmp/snmptrapd.conf is the configuration file of the snmptrapd daemon, which calls the trap handler snmptrapfmthdlr. /usr/sbin/snmptrapfmt is the executable of the application. /usr/sbin/snmptrapfmthdlr is the executable of the trap handler. /var/run/snmptrapfmt.p is the communication pipe between the trap handler snmptrapfmthdlr and the formatter snmptrapfmt. /var/tmp/snmptrapfmt.trc is the trace file if the option -d is specified. /var/log/snmptrapfmt.log is the log file as specified in the configuration file. SEE ALSO
snmptrapfmthdlr(8), syslog(8), variables(5), RFC 1155, RFC 1156, RFC 1157, SNMP Security Internet Drafts 4th Berkeley Distribution 19 DECEMBER 2002 SNMPTRAPFMT(8)
All times are GMT -4. The time now is 08:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy