Automating 'newgrp' command - how?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automating 'newgrp' command - how?
# 1  
Old 01-04-2010
Automating 'newgrp' command - how?

Hi,

I have to add the 'newgrp' command to my login (.cshrc) script.

The problem is that if I add it, it comes to infinite look, since newgrp opens new shell again and again.

How to automate the newgrp when I have to login, and avoid that loop?

Currently I'm thinking of a condition that creates temporary file and run the newgrp if that file exists (one time only). Do you have a better idea?

Thanks in advance
# 2  
Old 01-04-2010
Cannot test it right now, but did you try something like this:

Code:
exec newgrp ...

# 3  
Old 01-04-2010
Hi.

exec seems to make matters worse.

Try putting the call to newgrp in your $HOME/.login script. .login only gets executed once at login.

If you need to run newgrp with the - (or -l) flag then your idea of a temporary file might be better
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Newgrp fails on only 1 group

I have a handful of users who can't 'newgrp' to one specific group from Solaris 9 and 10 nodes and always get this prompt: newgrp: Password: We never get prompted by 20+ other groups and this group never prompts for a password from Red Hat Linux nodes. Authentication comes from AD and there's... (4 Replies)
Discussion started by: rnae20
4 Replies

2. Shell Programming and Scripting

How to set up newgrp on .profile?

Hello all, I am having an issue setting up an environment on .profile. I want to set up my .profile in that way that everytime I login to the host, it should automatically set up my group. I tried the folllowing but it doesn't work. It is on the solaris OS. HOSTNAME=$(hostname) if ] || ]... (14 Replies)
Discussion started by: Pateltiger
14 Replies

3. Programming

awk script for automating the other commercial software command lines

Dear All I need awk script to automated the other software command lines. I am having input files like "shape_eon_input_1.oeb.gz" to "shape_eon_input_968.oeb.gz" total of 968 files. For each files i have to run command line " eon -dbase shape_eon_input_1.oeb.gz -besthits 47000 -prefix... (20 Replies)
Discussion started by: bala06
20 Replies

4. Shell Programming and Scripting

How to use newgrp or sg in user mode without password prompt?

Hi, Is it possible to call newgrp or sg from user mode without password prompt in a Linux script? Thank you. hce (2 Replies)
Discussion started by: hce
2 Replies

5. Shell Programming and Scripting

problem in automating "fdisk" command using send and expect

hi i want to automate fdisk command . i spawned a process containing fdisk command from a process and tried to send the options to fdisk promt from that process. but that spawed process is notstarting itself help me out trying for two days :wall: my code: #!/bin/bash echo... (5 Replies)
Discussion started by: jagak89
5 Replies

6. Shell Programming and Scripting

Issues with automating SFTP command

Hi All, I am currently looking at automating the steps that I follow to download log files from putty to desktop. I connect to a client's machine through citrix desktop. I am required to download quite a number of application logs to identfiy the issues in production. Steps that is being... (3 Replies)
Discussion started by: krackjack84
3 Replies

7. Shell Programming and Scripting

what is the right way to use newgrp in script

my requirement is $ id user o/p for the above command $ uid=1(user) gid=2(x) a user is involved in 3 groups x,y,z whenever the user try to execute a script, script should ask for the group as input from user ,assume the group he wants to change as Y and the rest of the... (3 Replies)
Discussion started by: ram_unx
3 Replies

8. Shell Programming and Scripting

Automating Logform Command in a script

Hi all I am trying to create a script to automate the creating of filesystems. The problem I am having is as follows:- After creating the Log Logical Volume, I want to format it, using the logform command. The Logform command expects user intervention, by typing 'y' and 'enter' to continue.... (2 Replies)
Discussion started by: TheDoc
2 Replies

9. UNIX for Dummies Questions & Answers

newgrp in a script

I want to do these commands in a script: if the user name is 'toto' then the user switch to the group toto_group and then 2 others scripts are launched. Unfortunately, after the command 'newgrp' the 2 scripts are not launched correctly. But if I do the same, by hand, one line per one line, it... (11 Replies)
Discussion started by: Nathe
11 Replies

10. UNIX for Advanced & Expert Users

newgrp command

I'd like to make an alias of commands which contains the command newgrp. exple: alias my_cmde newgrp toto; my_pg & this line doesn't work. why ? Thanks for your help (2 Replies)
Discussion started by: Nathe
2 Replies
Login or Register to Ask a Question