Re: Korn Shell Wrappers for Perl Module Functions?
by lhoward (Vicar) on Jul 10, 2001 at 20:37 UTC
|
How about passing the arguments as environmental variables?
doit.ksh
#!/bin/ksh
export FOO=123
export BAR=234
./doit.pl
doit.pl
#!/usr/bin/perl -w
use strict;
#do something with $ENV{FOO} and $ENV{BAR}
| [reply] [d/l] [select] |
Re: Korn Shell Wrappers for Perl Module Functions?
by Malkavian (Friar) on Jul 10, 2001 at 20:33 UTC
|
One way or another, the script you call will be visible to a ps command.
If, however, you're not worried about the script itself showing up, but the argument list you send to it, then the solution is to use the environment space in the shell.
The first part of the shell script sets the environment arguments, then you call the wrapper script, which then pulls those values out of ENV space.
You'll then see the scriptname showing up on a ps with no args
It's kludgy and nasty, but it'll do the job.
This may not be what you really wanted, but it's a thought.. :)
Cheers,
Malk | [reply] |
Re: Korn Shell Wrappers for Perl Module Functions?
by Anonymous Monk on Jul 10, 2001 at 20:45 UTC
|
echo Var1=$var1 Var2=$var2|perlscript
? You can see the environmentspace with ps too. | [reply] [d/l] |
|
|
Perhaps what the ps is showing is the args to echo, not the args to the perl script?
| [reply] |
|
|
| [reply] |
|
|
|
|
| [reply] |
Re: Korn Shell Wrappers for Perl Module Functions?
by runrig (Abbot) on Jul 10, 2001 at 20:36 UTC
|
If they want a Korn shell function to execute from a shell script, then it may be more efficient to just do it as a Korn shell function. It'll be one less process to spawn. Then again, depending on the function maybe it would be worthwhile to write the Perl script.
You could pass arguments by environment variables, of course, but command line args are usually better especially if you want to optionally run this script from the command line. Or you could take command line args if they're there, but default to the %ENV hash if there are no command line args.
Besides, 'ps -f' on my system anyway, would show that it IS a perl script running no matter what argument passing you used. (Or are you just worried about the parameters showing?) | [reply] |
|
|
| [reply] |
Re: Korn Shell Wrappers for Perl Module Functions?
by sierrathedog04 (Hermit) on Jul 10, 2001 at 21:05 UTC
|
Update: Yes, I am worried about the parameters showing up when someone runs 'ps'. It is a matter of complete indifference to me if users can merely tell that I am running Perl behind the scenes. The suggestion that I use environmental variables sounds promising. My understanding is as follows:
- My understanding is that if a Korn shell sets an environmental variable and then calls a Perl script the environmental variable will be visible to the Perl script.
- The same is true in reverse. If a Perl script sets an environmental variable and then exits then the Korn script that called the Perl script can also see that environmental variable.
- Also, if a Korn shell script sets an environmental variable then only someone logged in as that user can see the variable.
- Finally, concurrent users will not confuse the shell. Each environmental variable will exist only within the process that called it.
As they say at the Paris Perlmongers meetings, 'N'est-ce que pas?" Is what I have said about environmental variables in Korn and Perl true?
Recursive Update: Clearly there is more involved here than simply swapping environmental variables to and from Korn and Perl. Therefore, the best solution given the user requirement to provide a Korn shell function is simply to do the whole shmear in Korn.
By the way, it occurred to me that the Korn shell would have had more success as a scripting language if the developer had named it something imaginative like 'Tortilla'.
| [reply] |
|
|
Not true. Environmental variables are passed from shell to perl,
not back (Correctly from parent to child). Environmental variables could be seen from all users per ps,
but are not shown by default. Two points out of four. See here!
| [reply] |
|
|
Environment vars will only be seen if you pipe them to the script, as you've done in your link.
However, if you set them on a line by line basis in a shell script they won't be visible.
Malk.
| [reply] |
|
|
|
|
|
|
|
|