LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-13-2001, 05:55 PM   #1
bobsey
LQ Newbie
 
Registered: Apr 2001
Posts: 1

Rep: Reputation: 0
Unhappy


This is actually not just for Linux; I'm searching for a POSIX-compliant solution. I'm trying to set up a perl (and perhaps csh) script to temporarily switch the user's group to one of it's supplementary groups, "do it's thing", then switch back to it's primary group once the script has finished. The results I've had with the newgrp command are less than elegant. It seems as though I'm still stuck with the supplementary group assignation after the script ends. Adding another newgrp command at the end of the script to set it back to the primary just adds another shell layer. Putting "exit" or "logout" at the end of the script does nothing although typing "exit" on the command line after the script has completed sets it back to the way I want it. Any guidance would be appreciated.
 
Old 04-13-2001, 10:05 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Have you tried sg? It sounds like it may not meet your requirements though. Not csh.

This is from the newgrp man page:

Quote:
The sg command works similiar to newgrp but does not
replace the user's shell, so upon exit from a sg command,
you are returned to your previous group ID. sg also
accepts a command. The command will be executed with the
Bourne shell and must be enclosed in quotes.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script for csh or bash unihiekka Programming 5 10-15-2005 09:51 AM
Getting PID from a system command in Linux perl script sumbabs Linux - General 1 03-03-2005 10:38 AM
PERL script OK at command line, not in browser alvo Programming 4 12-19-2004 08:28 AM
Perl shell-out to script dunna work. Works on command line. Why? jlangelier Linux - Software 1 08-28-2004 02:00 AM
How to run a bash command in the background from perl script professorfrink Programming 3 11-13-2003 03:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration