Discussion:
parsing help output of scanimage there has got to be a better way?
Add Reply
Jeff Sadowski
2017-09-18 19:28:23 UTC
Reply
Permalink
Raw Message
I am trying to design a web interface like phpsane (developer no longer
working on it)
It looks like he had issue also with parsing the help output as phpsane
didn't work for me.
I had created something like phpsane myself a while ago and was using it
until I upgraded and I lost my web interface.
I was looking if I had to create my own again or if something is out there.

I couldn't find anything so I went at creating my own again. I am really
satisfied with the way I do my php and having it spawn a separate php job
that runs in the background. I had originally customised mine for my
printer but now I wanted to make it more dynamic since I had to rebuild it
anyways.

The extremely hard part is coming up with a way to parse the stdout of
"scanimage -h"
Is there a good way to to this with regular expressions or something.

I have some ways I'm working on that I keep breaking up the string a bit at
a time but it seems exhausting coming up with a parser for pulling the
command line arguments and available options out of that.

Attached is the stdout output of my "scanimage -h"
My first approach was to go after every line that started with - or space -
As you can see in my attached output that approach won't work.
Any suggestions on how to start? Any suggestions on a place to share my
code with others?
I have just started using git on bitbucket for a class I am taking would
that be a good place?
Jeff
2017-09-18 20:15:20 UTC
Reply
Permalink
Raw Message
Post by Jeff Sadowski
The extremely hard part is coming up with a way to parse the stdout of
"scanimage -h"
Is there a good way to to this with regular expressions or something.
If you look at the source of gscan2pdf
(https://sourceforge.net/p/gscan2pdf/code/ci/master/tree/lib/Gscan2pdf/Scanner/Options.pm),
the _parse_scanimage_output() method does what you want.

It is written in Perl, but PHP is not very different.

Regards

Jeff
Jeff Sadowski
2017-09-18 20:56:21 UTC
Reply
Permalink
Raw Message
Post by Jeff
Post by Jeff Sadowski
The extremely hard part is coming up with a way to parse the stdout of
"scanimage -h"
Is there a good way to to this with regular expressions or something.
If you look at the source of gscan2pdf
(https://sourceforge.net/p/gscan2pdf/code/ci/master/tree/
lib/Gscan2pdf/Scanner/Options.pm),
the _parse_scanimage_output() method does what you want.
Thank you, I understand both well I should have not trouble converting it.
It is written in Perl, but PHP is not very different.
Regards
Jeff
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
Jeff Sadowski
2017-09-18 21:01:05 UTC
Reply
Permalink
Raw Message
Post by Jeff
Post by Jeff Sadowski
The extremely hard part is coming up with a way to parse the stdout of
"scanimage -h"
Is there a good way to to this with regular expressions or something.
If you look at the source of gscan2pdf
(https://sourceforge.net/p/gscan2pdf/code/ci/master/tree/lib
/Gscan2pdf/Scanner/Options.pm),
the _parse_scanimage_output() method does what you want.
Thank you, I understand both well I should have not trouble converting it.
Ahh, I see ignore the common options and put them in manually. clear way of
getting around the issue. ;-)
Post by Jeff
It is written in Perl, but PHP is not very different.
Regards
Jeff
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
Loading...