Hi,
Thanks for the suggestion.
There are some tasks which are directly tied to the group-id. Owing to the requirement it may happen my perl script need to switch groups to achieve a specific task. So my plan is to change to a new group with new grp command after exporting the Environment/required variables from the current shell. After the newgrp system command from a perl script could not satisfy my need I tried including the command in a separate .cshrc file and then just sourcing that file from a perl script. But this job could not again be executed from perl script . The perl script returns error telling the sourced file could not be found. Moreover changing the scripts group permission wont do hold good for my case.
I am at bay now !!

Regards,
Suvajit

Shawn Corey wrote:

Suvajit Sengupta wrote:

Hi,
I want to login into a new group using 'newgrp' UNIX command.Every newgrp command invokes a new shell. But when I am trying to execute this system command from a perl script the script is terminating and returning the prompt of the new shell . Can anyone suggest on what can be done to change into a new group from within perl script?


Short answer: You can't.

Long answer:

The newgrp command will always run a new shell regardless if it succeeds or fails. What you can do instead is set the effective group id for the script.

1. Change the script's group to the group you want it to work under (see `man chgrp`).

2. Change the script's "set group id on execution" flag (see `chmod`).

The script will now run under the new group.

See `perldoc perlvar` and search for $) and $(.




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to