Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Error: sh: -c: line 0: unexpected EOF while looking for matching `''

by dbmathis (Scribe)
on May 20, 2009 at 16:26 UTC ( #765276=perlquestion: print w/ replies, xml ) Need Help??
dbmathis has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I have looked at this and looked at this and can't figure out where the error below is coming from. Any help would be GREATLY appreciated.

I may be going about this wrong anyway, I have not done much directory type programming so feel free to flame me regarding my approach.

#!/usr/bin/perl -w use strict; use Data::Dumper; use File::Find; no warnings 'File::Find'; #my $find = qr/window.open(\"form\/form.php\",\"Neu\",\"scrollbars=no, +width=550 ,height=580\");/; #my $replace = qr/window.location=\"form\/form.php\";/; my @files; chomp( my @base = `locate -b public_html | grep -v 'html\.' 2>/dev/nul +l`); for my $base ( @base ) { find(\&html, $base ); sub html { if ( $File::Find::name =~ /^\/.*\.html$/ ) { push @files, `grep -il 'window.open("form/form.php","Neu", +"scrollbars=no,width=550 ,height=580");' '$File::Find::name' 2>/dev/n +ull`; } } }
# ./fix-popups sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file

Comment on Error: sh: -c: line 0: unexpected EOF while looking for matching `''
Select or Download Code
Re: Error: sh: -c: line 0: unexpected EOF while looking for matching `''
by ikegami (Pope) on May 20, 2009 at 16:49 UTC
    I suspect you have a quote in the value of $File::Find::name. The following could be used to generate the shell literal (instead of "'$File::Find::$name'"):
    sub to_sh_literal { my ($s) = @_; # Assuming bourne shell. $s =~ s/'/'\\''/g; $s = "'$s'"; return $s; }

    But why are you using grep (the external tool) at all?

    Update: Removed encode since file names are bytes, not text.

Re: Error: sh: -c: line 0: unexpected EOF while looking for matching `''
by graff (Chancellor) on May 21, 2009 at 01:54 UTC
    Since you're relying heavily on shell commands anyway, why not just do it like this?
    locate -b public_html | grep -v 'html\.' | xargs -I % find % -name '*.html' -print0 | xargs -0 grep -li 'blahblah...' > path-name.list 2>/dev/null
    If you want a perl script to do something with that list of files, just set up the script to read the path-name list as input. If you use while(<>) your script can either read from a list file (as produced by my example above), or you could just tack it on at the end of the pipe.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://765276]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-09-20 06:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (155 votes), past polls