lists on 19 Nov 2007 17:32:50 -0000 |
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > lists@linuxnotes.net wrote: >> Hi all, >> >> I have a bash script that I need to run from within a Perl script and >> capture the output. My script works fine until it hits a parentheses in >> an argument and then I get: >> >> sh: -c: line 0: syntax error near unexpected token `(' >> >> I understand that if there are arguments in backticks the command is >> sent >> to the shell for interpretation, but if I run the command outside of my >> Perl script it works fine so I am not sure where I am getting the error >> from. I have used quotemeta() to escape all the special characters. > > Can you provide some samples? I haven't used quotemeta before but > according to it's docs it doesn't look like what you want: > > [michael@orion(~)] perldoc -f quotemeta > quotemeta EXPR > quotemeta > Returns the value of EXPR with all non-"word" characters > backslashed. (That is, all characters not matching > "/[A-Za-z_0-9]/" will be preceded by a backslash in the > returned string, regardless of any locale settings.) > This is the internal function implementing the "\Q" > escape in double-quoted strings. > > If EXPR is omitted, uses $_. The script finds all the files in Recent folders on a Windows box and then runs strings on each and greps out the path (bash/fileLoc.sh). The output in then put in a table. I was using quotemeta to escape the spaces in the file names, which works like a champ. Here is a portion of the script: $fullPath = $dir . "/" . $line; chop $fullPath; $fullPath = quotemeta($fullPath); $line =~ s/\.lnk$//i; $fileLoc = `bash/fileLoc.sh $fullPath $line`; print "<tr><td>$line</td><td>$fileLoc</td></tr>"; $fullPath looks like this after quotemeta: \/media\/hda2\/Documents\ and\ Settings\/CDowns\/Application\ Data\/Microsoft\/Office\/Recent\/SO\ 2007\-36\ \(EN\ Printer\ Replacement\ Project\)\.doc\.LNK Jon > - -- > Michael Greb > Linode.com, LLC > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (Darwin) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFHQboq0Qbp4bPZvesRAl4aAJ4wXhIDZm8o2KLhWmgwSBn77quxCwCfYnt1 > j1JfixcBS1fwBKkuIPTbeks= > =nogh > -----END PGP SIGNATURE----- > ___________________________________________________________________________ > Philadelphia Linux Users Group -- > http://www.phillylinux.org > Announcements - > http://lists.phillylinux.org/mailman/listinfo/plug-announce > General Discussion -- > http://lists.phillylinux.org/mailman/listinfo/plug > ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|