Re: sed from a shell script - invalid command code

2003-12-11 Thread Malcolm Kay
On Thu, 11 Dec 2003 01:10, Jez Hancock wrote:
 #!/bin/sh
 sed=/usr/bin/sed
 passwd_file=/etc/passwd

 ignore_users=root|toor|daemon|operator|bin|tty|kmem|games|news|man|smmsp|b
ind|uucp|xten|pop|nobody|mysql|www|sshd|ftp|cyrus

 cmd=$sed -E -e '/^(#|$ignore_users)/d' -e 's/:.*//' $passwd_file

 users=`cmd`

I believe you want
  users=`eval $cmd`
for this line

 echo $users

Malcolm

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sed from a shell script - invalid command code

2003-12-10 Thread Jez Hancock
On Wed, Dec 10, 2003 at 02:40:58PM +, Jez Hancock wrote:
 I'm trying to get the following Bourne shell script to output a list of
 all users on the server with the exception of those listed in the
 $ignore_users variable:
 
 -snip-
 #!/bin/sh
 sed=/usr/bin/sed
 passwd_file=/etc/passwd
 
 ignore_users=root|toor|daemon|operator|bin|tty|kmem|games|news|man|smmsp|bind|uucp|xten|pop|nobody|mysql|www|sshd|ftp|cyrus
 
 cmd=$sed -E -e '/^(#|$ignore_users)/d' -e 's/:.*//' $passwd_file
 
 users=`cmd`
 echo $users
 -snip-
Solved - solution was:

#!/bin/sh
sed=/usr/bin/sed
passwd_file=/etc/passwd

ignore_users=root|toor|daemon|operator|bin|tty|kmem|games|news|man|smmsp|bind|uucp|xten|pop|nobody|mysql|www|sshd|ftp|cyrus

users=`$sed -E -e '/^(#|$ignore_users)/d' -e 's/:.*//' $passwd_file`

echo $users

-- 
Jez Hancock
 - System Administrator / PHP Developer

http://munk.nu/
http://jez.hancock-family.com/
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]