Mike,

If you don't mind changing the script, go ahead and try the below:

cat usefile | awk -F: '{ print $1 }'

This will list all the names in "userfile", in case you want them in another file, all you have to do is redirect the output of the command to the desired file.

Regards,

Ziad






From: Mikevl <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
Subject: RE: Shell scripting help
Date: Mon, 2 Dec 2002 08:17:21 +1300
MIME-Version: 1.0
Received: from mc8-f1.law1.hotmail.com ([65.54.253.137]) by mc8-s7.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Sun, 1 Dec 2002 11:18:19 -0800
Received: from listman.redhat.com ([66.187.233.211]) by mc8-f1.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Sun, 1 Dec 2002 11:18:19 -0800
Received: from listman.redhat.com (localhost.localdomain [127.0.0.1])by listman.redhat.com (Postfix) with ESMTPid E1C763F3F8; Sun, 1 Dec 2002 14:18:04 -0500 (EST)
Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254])by listman.redhat.com (Postfix) with ESMTP id 2F3193F3F4for <[EMAIL PROTECTED]>; Sun, 1 Dec 2002 14:17:41 -0500 (EST)
Received: (from mail@localhost)by int-mx1.corp.redhat.com (8.11.6/8.11.6) id gB1JHf410483for [EMAIL PROTECTED]; Sun, 1 Dec 2002 14:17:41 -0500
Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31])by int-mx1.corp.redhat.com (8.11.6/8.11.6) with SMTP id gB1JHeD10476for <[EMAIL PROTECTED]>; Sun, 1 Dec 2002 14:17:40 -0500
Received: from smtp-3.paradise.net.nz (smtp-3b.paradise.net.nz [202.0.32.212])by mx1.redhat.com (8.11.6/8.11.6) with SMTP id gB1IqqP32294for <[EMAIL PROTECTED]>; Sun, 1 Dec 2002 13:52:52 -0500
Received: from dssserver.dounsix.co.nz (203-79-66-138.adsl-wns.paradise.net.nz [203.79.66.138])by smtp-3.paradise.net.nz (Postfix) with ESMTP id 7CAD1AE074for <[EMAIL PROTECTED]>; Mon, 2 Dec 2002 08:17:32 +1300 (NZDT)
Received: by localhost with Internet Mail Service (5.5.2650.21)id <WHN28RXJ>; Mon, 2 Dec 2002 08:17:37 +1300
Delivered-To: [EMAIL PROTECTED]
Message-ID: <51065A926D41D311899F00A0C9B8E8263AC07E@localhost>
X-Mailer: Internet Mail Service (5.5.2650.21)
X-Loop: [EMAIL PROTECTED]
Sender: [EMAIL PROTECTED]
Errors-To: [EMAIL PROTECTED]
X-BeenThere: [EMAIL PROTECTED]
X-Mailman-Version: 2.0.1
Precedence: bulk
List-Help: <mailto:[EMAIL PROTECTED]?subject=help>
List-Post: <mailto:[EMAIL PROTECTED]>
List-Subscribe: <https://listman.redhat.com/mailman/listinfo/redhat-list>,<mailto:[EMAIL PROTECTED]?subject=subscribe>
List-Id: General Red Hat Linux discussion list <redhat-list.redhat.com>
List-Unsubscribe: <https://listman.redhat.com/mailman/listinfo/redhat-list>,<mailto:[EMAIL PROTECTED]?subject=unsubscribe>
List-Archive: <https://listman.redhat.com/pipermail/redhat-list/>
X-Original-Date: Mon, 2 Dec 2002 08:17:21 +1300
Return-Path: [EMAIL PROTECTED]
X-OriginalArrivalTime: 01 Dec 2002 19:18:19.0523 (UTC) FILETIME=[684E9D30:01C2996E]

Thanks

This program will extract names from an input and put them into another
command.

userfile=$1
s=0
for i in 'cat $userfile ';do
# s=$s+1
NAME='cut -d : -f1'
echo $NAME
# echo $s
done

The output is as below instead of a list of names as I would like

[root@Lizzi root]# ./addscusers scusers
cut -d : -f1
[root@Lizzi root]#

Many thanks
Mike

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Adam H. Pendleton
Sent: Monday, 2 December 2002 07:56
To: [EMAIL PROTECTED]
Subject: RE: Shell scripting help


*This message was transferred with a trial version of CommuniGate(tm) Pro*
Change the line:

$NAME='cut -d : -f1'

to be:

NAME='cut -d : -f1'

$NAME as a left-hand operator causes expansion, which in this case probably
expands to "", leaving you with:

='cut -d : -f1'

which is the text of your error message.

ahp

> -----Original Message-----
> From: Mikevl [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, December 01, 2002 13:52
> To: Redhat-List (E-mail)
> Subject: Shell scripting help
>
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> Thanks Robert
>
> No I didn't name the file useradd it has quite a different name
> The cut command works from the command line but from the script I get
>
> [root@Lizzi root]# ./addscusers scusers
> ./addscusers: =/bin/cut -d : -f1: No such file or directory
>
> Many thanks
>
> Mike
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Robert P. J. Day
> Sent: Monday, 2 December 2002 07:08
> To: [EMAIL PROTECTED]
> Subject: Re: Shell scripting help
>
>
> On Sun, 1 Dec 2002, Bill Horne wrote:
>
> > ----- Original Message -----
> > From: "Mikevl" <[EMAIL PROTECTED]>
> >
> >
> > > Hi
> > >
> > > Can anybody help with this simple script
> > >
> > > Command is useradd userfile
> > >
> > >
> > > useradd
> > > userfile=$1
> > > s=0
> > > for i in 'cat $userfile ';do
> > > $NAME='cut -d : -f1'
> > > echo $NAME
> > > done
> >
> > info cut.
>
> *please* tell me you didn't actually name the executable
> script file "useradd".
>
> rday
>
>
>
> --
> redhat-list mailing list
> unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
> https://listman.redhat.com/mailman/listinfo/redhat-list
>
>
>
> --
> redhat-list mailing list
> unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
> https://listman.redhat.com/mailman/listinfo/redhat-list





--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list



--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus



--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to