Sponsored Content
Full Discussion: Frustrating Groups loop
Top Forums Shell Programming and Scripting Frustrating Groups loop Post 302669767 by MaindotC on Wednesday 11th of July 2012 09:57:26 AM
Old 07-11-2012
Quote:
Originally Posted by Chubler_XL
The "no such user" message is probably being output to stderr to capture it you will need to redirect stderr to stdout like this:
Code:
USER_HAS_GROUPS="`id $i 2>&1`"

Here is another thought, why not examine the return value from the id command something along the lines of this:
Code:
while read i
  if id $i > /dev/null 2>&1
  then
    USER_LDAP_GROUPS="`id $i | cut -d\= -f4 | sed 's/([^()]*)//g;s/,/ /g'`"
    echo $USER_LDAP_GROUPS
  else
     echo "Invalid user $i"
  fi
done < txt1

Not only does that kludge not work for me but I don't understand why...it keeps saying "-bash: syntax error near unexpected token `done'". I believe the syntax is correct...there's a while followed by a done, I even put in a "do" just in case. The if statement is properly enclosed with fi...not sure why this is happening but I can't verify your suggestion.
 

10 More Discussions You Might Find Interesting

1. Linux

Frustrating!

Hi All I have an extremely frustrating problem with my Mandrake 9.1 machine. When I am in KDE no browser at all will resolve hostnames. Networking is fine, as I can reach websites via IP address, however hostnames just don't work! When I conduct 'nslookup' or 'host' queries via the command line,... (2 Replies)
Discussion started by: saabir
2 Replies

2. Shell Programming and Scripting

Frustrating Disk space script

This my frustrating disk space script that is supposed to send me a email whenever the disk space reaches 90% but this has some problem that just would not work ..can anyone please tell me when im going wrong #!/bin/ksh sendemail=-1 space=`df -bhk /users/siebelserver |awk '{print$5}'` echo... (4 Replies)
Discussion started by: vivsiv
4 Replies

3. AIX

Where are my groups

Hello A couple of weeks ago, I added a user to an AIX 5.3 system. I go to add one today, and it appears that when creating a user in smit, I cannot see any groups. No primary groups No Group set No Admin Groups The /etc/group and etc/secuity/group files seem to be intact. I did... (4 Replies)
Discussion started by: mhenryj
4 Replies

4. Solaris

groups

how to create 1000 users in 1 group (0 Replies)
Discussion started by: tirupathi
0 Replies

5. Solaris

groups

1 user in member of 4 groups find file permissions and default group (1 Reply)
Discussion started by: tirupathi
1 Replies

6. UNIX for Dummies Questions & Answers

Frustrating but simple preference question

So I am set up on a new box for work here and I have a frustrating preference issue. Whenever I hit backspace, it deletes a whole word instead of a single character. I understand that this is generally the functionality of hitting ctrl-backspace. I tried googling for a solution and dabbled... (3 Replies)
Discussion started by: jasondj
3 Replies

7. UNIX for Dummies Questions & Answers

Groups

Must I be in a group? I am using Ubuntu and am the only user on my PC. I know how to change groups but do not see a way to not be in a group. Any help would be appreciated. (2 Replies)
Discussion started by: nthepines
2 Replies

8. Shell Programming and Scripting

Frustrating error special character <96>

Hiya Folks, Wondering if anybody has ran into this before, it's driving me nuts! Searching on this in the forums didn't turn up anything that was any help. My script is going through a csv file I have, running ksh under Cygwin. The code I have is... REQUEST_TYPE=$(grep REQ $FILES |... (3 Replies)
Discussion started by: jtollefson
3 Replies

9. Ubuntu

PPPOE + Ubuntu = Frustrating

Hii everyone, I will be explaining what kind of problem I am having with Ubuntu and PPPOE. I have dual booted my PC with Win 7 and Ubuntu 10.10 Previously, whenever I use to start my ubuntu, internet automatically used to start up.. .no problems. I had created a DSL connection through... (0 Replies)
Discussion started by: zsycho
0 Replies

10. Shell Programming and Scripting

Frustrating in splitting text files

Duplicate threads merged Dear all, I have been working with a very large text file manually. I'm ordering how to do this with a script. The gamma should be straightforward: I just want split the text into multiple files. The file name should be "CP1", "TS1 for the second step", "PR1 for... (3 Replies)
Discussion started by: liuzhencc
3 Replies
EVAL(3) 								 1								   EVAL(3)

eval - Evaluate a string as PHP code

SYNOPSIS
mixed eval (string $code) DESCRIPTION
Evaluates the given $code as PHP. Caution The eval(3) language construct is very dangerous because it allows execution of arbitrary PHP code. Its use thus is discouraged. If you have carefully verified that there is no other option than to use this construct, pay special attention not to pass any user provided data into it without properly validating it beforehand. PARAMETERS
o $code - Valid PHP code to be evaluated. The code mustn't be wrapped in opening and closing PHP tags, i.e. 'echo "Hi!";' must be passed instead of '<? echo "Hi!"; >'. It is still possible to leave and reenter PHP mode though using the appropriate PHP tags, e.g. 'echo "In PHP mode!"; ?>In HTML mode!<? echo "Back in PHP mode!";'. Apart from that the passed code must be valid PHP. This includes that all statements must be properly terminated using a semicolon. 'echo "Hi!"' for example will cause a parse error, whereas 'echo "Hi!";' will work. A return statement will immediately terminate the evaluation of the code. The code will be exe- cuted in the scope of the code calling eval(3). Thus any variables defined or changed in the eval(3) call will remain visible after it terminates. RETURN VALUES
eval(3) returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. If there is a parse error in the evaluated code, eval(3) returns FALSE and execution of the following code continues normally. It is not possible to catch a parse error in eval(3) using set_error_handler(3). EXAMPLES
Example #1 eval(3) example - simple text merge <?php $string = 'cup'; $name = 'coffee'; $str = 'This is a $string with my $name in it.'; echo $str. " "; eval("$str = "$str";"); echo $str. " "; ?> The above example will output: This is a $string with my $name in it. This is a cup with my coffee in it. NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. Tip As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example). Note In case of a fatal error in the evaluated code, the whole script exits. SEE ALSO
call_user_func(3). PHP Documentation Group EVAL(3)
All times are GMT -4. The time now is 04:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy