CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
piped Perl command line problem

 



jlk4p
New User

Jul 31, 2007, 6:48 AM

Post #1 of 6 (3384 views)
piped Perl command line problem Can't Post

Folks,

I'm maintaining a script process (which has been working for a couple years) that includes a shell command that ssh's to another server and executes a Perl script to get some XML data returned, which is then piped to a Perl single line command:


Code
ssh server.name.domain path/to/command.pl | perl -ne 'if ( /<pid>((dummy|uva-lib):[0-9]*)<\\/pid>/ ) { print \"$1\\n\"  }'


I have confirmed that the ssh process/Perl script is still working with the authentication configuration being used. And it returns data in this format


Code
<?xml version="1.0" encoding="UTF-8"?> 
<pidList xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fedora.info/definitions/1/0/management/ https://repo.lib.virginia.edu:18443/getNextPIDInfo.xsd">
<pid>dummy:50431</pid>
<pid>dummy:50432</pid>
</pidList>


It seems that the single line command that checks for a pattern match is no longer working. I'm wondering if the Mac OS X 10.4 system this runs on may have had a s/w update performed on it that updated the Perl version (5.8.6) and made this code no longer functional. From my work with regular expressions, everything looks fine in this code. But it generates this error:

Bareword found where operator expected at -e line 1, near "/<pid>((dummy|uva-lib):[0-9]*)<\\/pid"
(Missing operator before pid?)
syntax error at -e line 1, near "/<pid>((dummy|uva-lib):[0-9]*)<\\/pid"
Search pattern not terminated at -e line 1.

Any suggestions would be appreciated.

Thanks,
Jack


KevinR
Veteran


Jul 31, 2007, 9:50 AM

Post #2 of 6 (3381 views)
Re: [jlk4p] piped Perl command line problem [In reply to] Can't Post

look like there is one too many back slashes here:

<\\/pid>

change it to:

<\/pid>

and try again.
-------------------------------------------------


jlk4p
New User

Jul 31, 2007, 10:21 AM

Post #3 of 6 (3380 views)
Re: [KevinR] piped Perl command line problem [In reply to] Can't Post

Kevin, thanks for the response. Unfortunately that doesn't seem to fix the problem. It just changes the error to

Can't find string terminator '"' anywhere before EOF at -e line 1.


KevinR
Veteran


Jul 31, 2007, 11:59 AM

Post #4 of 6 (3376 views)
Re: [jlk4p] piped Perl command line problem [In reply to] Can't Post

OK, another guess:


Code
perl -ne "if ( /<pid>((dummy|uva-lib):[0-9]*)<\/pid>/ ) { print \"$1\\n\"  }"



used double-quotes instead of single-quotes around the code. You might also need to remove the first backslash from: \\n
-------------------------------------------------


jlk4p
New User

Aug 2, 2007, 10:58 AM

Post #5 of 6 (3364 views)
Re: [KevinR] piped Perl command line problem [In reply to] Can't Post

Kevin,

Thanks again for your response. I apologize for wasting everyone's time with this scripting problem. It appears to be working again on our Apple system without having to make any modification.

My apologies,
Jack


KevinR
Veteran


Aug 2, 2007, 12:00 PM

Post #6 of 6 (3362 views)
Re: [jlk4p] piped Perl command line problem [In reply to] Can't Post

No problem Jack. Cool
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives