Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Writing a parser

by Crackers2 (Parson)
on Jan 29, 2008 at 22:15 UTC ( [id://665021]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Writing a parser
in thread Writing a parser

Actually I just tried that and it won't work for me unless it's a true executable. If I try to use a perl script it actually gets passed to bash for some reason.

Unless I'm doing something wrong of course...

[root@spoonbill root]$ cat /sbin/parser #!/usr/bin/perl while (<>) { print "line: $_"; } [root@spoonbill root]$ cat scr #!/sbin/parser this is my file

This works:

[root@spoonbill root]$ /sbin/parser scr line: #!/sbin/parser line: this line: is line: my line: file line:

This does not:

[root@spoonbill root]$ ./scr ./scr: line 2: this: command not found ./scr: line 3: is: command not found ./scr: line 4: my: command not found Usage: file [-bciknsvzL] [-f namefile] [-m magicfiles] file... Usage: file -C [-m magic]

(All run as root just in case there was a permission problem)

Replies are listed 'Best First'.
Re^4: Writing a parser
by traveler (Parson) on Jan 30, 2008 at 00:01 UTC
    I'm sorry to tell you, but on Linux, that is not allowed. On * nix systems the exec family of calls is used to start processes. From the execve(2) man page:

    execve() executes the program pointed to by filename. filename must be either a binary executable, or a script starting with a line of the form "#! interpreter [arg]". In the latter case, the interpreter must be a valid pathname for an executable which is not itself a script, which will be invoked as interpreter [arg] filename

    Note where it says, "the interpreter...is not itself a script". So you will have to use
    #!/usr/bin/perl /path/to/my/script

    --traveler
Re^4: Writing a parser
by Zielony (Acolyte) on Jan 29, 2008 at 22:43 UTC
    Yeah, here is the problem. I was trying exactly as you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://665021]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-19 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found