urbansumo has asked for the wisdom of the Perl Monks concerning the following question:
How can I pass arguments into a script that I have curl & perl'd, for example. I have a project called apache2buddy.pl, its hosted on a polish domain, but its really just a perl script.
To execute the full script there are a couple of ways to do this:
1. the download and execute locally, or wget, method
# wget -O apache2buddy.pl apache2buddy.plthen
# perl apache2buddy.pl [+ optional args]I know that my script works in the desired way for example, once the script is downloaded with wget, I can issue the command:
# perl apache2buddy.pl --report ---------------------------------------------------------------------- +---------- Apache2buddy.pl report for server: perl.richardforth.co.uk (46.101.60. +103): Settings considered for this report: Your server's physical RAM: 490 MB Apache's MaxClients directive: 150 [ OK ] Your MaxClients setting is within an acceptable range. Max potential memory usage: 292.5 MB Percentage of RAM allocated to Apache 59.70 % ---------------------------------------------------------------------- +----------
BUT, my question is really regarding the "curl & perl" method, ie; How can I run the --report argument with:
# curl apache2buddy.pl | perlThis runs the "full" report but if I want a more concise output for example if in a "for" loop, against many servers, I like to run it with --report, can I do that with "curl & perl" or only after the wget method?
The reason to ask is as its really just a reporting tool and the potential need to run this across a farm of servers with the --report option, and I'd rather not have to download a copy on to each machine and run it locally.
You're all welcome to play with it, its not fully functional yet, you will obviously need apache webserver (2.2 at the moment) and a Linux Distro such as CentOS or RedHat for it to work as it stands, Im working on geting it to support apache2.4 and debian / ubuntu.
I digressed, annyway, if you know the answer to the above, I would be very grateful.
The only hacky way around this problem I have found is to use "tail" and "egrep" in combination:
# curl -s apache2buddy.pl | perl | tail -15 | egrep -i "\-|report|cons +idered|physical|acceptable|too high|potential|percentage" ---------------------------------------------------------------------- +---------- Apache2buddy.pl report for server: perl.richardforth.co.uk (46.101.60. +103): Settings considered for this report: Your server's physical RAM: 490 MB [ OK ] Your MaxClients setting is within an acceptable range. Max potential memory usage: 292.5 MB Percentage of RAM allocated to Apache 59.70 % ---------------------------------------------------------------------- +----------
However I was hoping that there may be a more elegant solution, I just cant figure out how to pass the argument --report with the curl & perl method
.For your comfort I include the usage below:
# perl apache2buddy.pl -h Usage: apache2buddy.pl [OPTIONS] If no options are specified, the basic tests will be run. -h, --help Print this help message -p, --port=PORT Specify an alternate port to check (de +fault: 80) -P, --php Include the PHP memory_limit setting w +hen making the recommendation -v, --verbose Use verbose output (this is very noisy +, only useful for debugging) -n, --nocolor Use default terminal color, dont try t +o be all fancy! -H, --noheader Do not show header title bar. -N, --noinfo Do not show informational messages. -K, --no-ok Do not show OK messages. -W, --nowarn Do not show warning messages. -L, --light-term Show colours for a light background te +rminal. -r, --report Implies -HNWK or --noinfo --nowarn --n +o-ok --noheader More information (1990's style info pages): http://apache2buddy.pl/about http://apache2buddy.pl/installation http://apache2buddy.pl/usage http://apache2buddy.pl/examples http://apache2buddy.pl/known_bugs http://apache2buddy.pl/feature_requests http://apache2buddy.pl/project_roadmap http://apache2buddy.pl/changelog
Kind Regards
Richard "urbansumo" Forth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I pass arguments into a script that I have curl & perl'd
by Corion (Patriarch) on Apr 12, 2015 at 08:38 UTC | |
by urbansumo (Novice) on Apr 12, 2015 at 18:41 UTC |