Sponsored Content
Full Discussion: Frustrating Groups loop
Top Forums Shell Programming and Scripting Frustrating Groups loop Post 302669797 by MaindotC on Wednesday 11th of July 2012 10:32:53 AM
Old 07-11-2012
Quote:
Originally Posted by jim mcnamara
Code:
while read i
do
  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

simple syntax error - missing "do"
I don't understand ! I inserted the "do" before and it still returned an error!
Code:
while read i; do; 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 "";fi; done < txt1
-bash: syntax error near unexpected token `;'

Jim yours works - thanks as always. I'm sure it's a syntax error on my part I'm just not readily seeing it. I tried several variations and still got an error.
 

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
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 08:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy