Item: Obtaining complete Unix command line that evoked script as a string
If there is a more appropriate list for this, let me know; the other
perl lists I've seen seem to specialised for this.
I'm trying to get the complete command line that invoked a script as
a string, that is the output of 'history 1'. Note this is not just
the arguments of the call to the script, but everything including
pipes and redirects, etc., e.g.
echo -n "Starting..." ; more some-stuff | \
doStuff.pl - 3 > save-here.out ; echo "done."
Ideally the perl interpreter would grab the complete command line as
its evoked and I'd access this via a variable. As this seem
problematic, more realistically, ideally the shell should maintain a
"current command" variable in the same fashion as the CWD variable,
which can then be exported and read. AFAIK this does exist... (I see
at the bottom of the bash FAQ that better environment variable
support of perl is on hopeful feature to be added... one day; I'd
very much like to see this.)
So... any ideas on something that does work, or am I just plain stuck?
I'm using the bash shell for what its worth. This may appear to be a
bash question, but I'm hoping for a perlish solution if possible!
You can achieve this in an ugly unreliable fashion by having the
caller set up an environment variable and read this in within the
scripts, e.g.
THISCMD=`history 1` ; doStuff.pl first-time
(and have doStuff read in $THISCMD)
But if the caller doesn't set up the environment variable on any
given command line, the previous value is used which is plain wrong.
Basically its untrustworthy, defeating my purpose for this, and there
doesn't seem to be any particularly easy way to make it trustworthy.
In any event, its also plain ugly!
Using bash's PROMPT_COMMAND to clear the value doesn't help, as this
doesn't apply if the command lines are within a non-interactive
script.
Grant
--
-------------------------------------------------------------------
Grant Jacobs Ph.D. BioinfoTools
ph. +64 3 478 0095 (office, after 10am) PO Box 6129,
or +64 27 601 5917 (mobile) Dunedin,
[EMAIL PROTECTED] NEW ZEALAND.
Bioinformatics tools: deriving knowledge from biological data
Bioinformatics tools - software development - consulting - training
15 years experience in bioinformatics ready to solve your problem
Check out the website for more details: http://www.bioinfotools.com
The information contained in this mail message is confidential and
may be legally privileged. Readers of this message who are not the
intended recipient are hereby notified that any use, dissemination,
distribution or reproduction of this message is prohibited. If you
have received this message in error please notify the sender immed-
iately and destroy the original message. This applies also to any
attached documents.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>