Hi again and thx John for you help. > > Hi all, > > Hello, > > > I'd like to get a script which allows me to get the gid of the > > user which is connected currently. > > I've done this "script" which is not very useful for me because > > I have to run it like this : > > id | myscript.pl > > You could run id inside your perl program. > > my $id_output = qx/id/; I didn't know how to execute a shell command into a perl script, thx.
> > My script is : > > > > while(<>) > > { > > if(/^uid=\d+.\w+.\sgid=(\d+)/) > > { > > $gid=$1; > > print "gid:$gid\n"; > > } > > } > > Perl supplies the User ID in $<, the Effective User ID in $>, the Group > ID in $( and the Effective Group ID in $). What's the difference between effective and non-effective, the answer are the same for : print "$>, $<\n" and idem for group Moreover when I do this print "gid: $)\n"; I get (a : gid: 0 10 6 4 3 2 1 0 not just 0. How to get just the true gid? > > print "gid: $(\n"; > > > To find the name assigned to $(: > > my $group = getgrgid $(; > print "Group: $group\n"; > > > To get all groups that $( belongs to: > > my @groups; > my $name = getpwuid $<; > while ( my @ent = getgrent ) { > push @groups, $ent[ 0 ] if $ent[ -1 ] =~ /\b$name\b/; > } > print "@groups\n" > > > > My aim is to change the ip address following the gid. > > The id program does not output an ip address. Yes I know. My first goal was to get the gid. Now I want to attribute ip address by gid, maybe thanks to : if ($( == 1000) { qx/ifconfig eth0 x.x.x.x up/; } elseif ($( == 1001) { qx/ifconfig eth0 x.x.x.y up/; } > > > > John > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]