getting a user's home dir (sed/awk?)

2006-04-17 Thread Erik Norgaard
Hi:

I am trying to create a script, the idea is to host a number of web
services, each running as a different process owned by a different user
bound to a non privileged port on localhost. The point is that each
service can be restarted without affecting other services and that any
security compromise does not propagate to other services.

Now, to start all servers I want to create a master script that looks up
the user's home directory and runs a script in a predefined path.

So the question is: given a username, how do I get the homedir?

I have found pw usershow user1 will return a line from the passwd
file, but that needs to be split chewed, and spit out. Seems awk can do
it but I have no clue.

Thanks, Erik

PS: Yes, I know, I could just create a perl script - but this time I
want to do it all using the tools in base.
-- 
Ph: +34.666334818  web: www.locolomo.org
S/MIME Certificate: www.daemonsecurity.com/ca/8D03551FFCE04F06.crt
Subject ID:  9E:AA:18:E6:94:7A:91:44:0A:E4:DD:87:73:7F:4E:82:E7:08:9C:72
Fingerprint: 5B:D5:1E:3E:47:E7:EC:1C:4C:C8:3A:19:CC:AE:14:F5:DF:18:0F:B9
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: getting a user's home dir (sed/awk?)

2006-04-17 Thread Patrick Bowen

Erik Norgaard wrote:


Hi:

I am trying to create a script, the idea is to host a number of web
services, each running as a different process owned by a different user
bound to a non privileged port on localhost. The point is that each
service can be restarted without affecting other services and that any
security compromise does not propagate to other services.

Now, to start all servers I want to create a master script that looks up
the user's home directory and runs a script in a predefined path.

So the question is: given a username, how do I get the homedir?

I have found pw usershow user1 will return a line from the passwd
file, but that needs to be split chewed, and spit out. Seems awk can do
it but I have no clue.

Thanks, Erik

PS: Yes, I know, I could just create a perl script - but this time I
want to do it all using the tools in base.
 



Erik;

How 'bout something like;

pw usershow user1 | awk -F: ' { print $9 } '

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


Re: getting a user's home dir (sed/awk?)

2006-04-17 Thread Svein Halvor Halvorsen
On 4/17/06, Erik Norgaard [EMAIL PROTECTED] wrote:
 I have found pw usershow user1 will return a line from the passwd
 file, but that needs to be split chewed, and spit out. Seems awk can do
 it but I have no clue.

cut is probably about the cheapest way to split a line:

pw usershow user1 | cut -d: -f9


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


Re: getting a user's home dir (sed/awk?)

2006-04-17 Thread Nikos Vassiliadis
On Monday 17 April 2006 19:48, Erik Norgaard wrote:
 Hi:

 I am trying to create a script, the idea is to host a number of web
 services, each running as a different process owned by a different user
 bound to a non privileged port on localhost. The point is that each
 service can be restarted without affecting other services and that any
 security compromise does not propagate to other services.

 Now, to start all servers I want to create a master script that looks up
 the user's home directory and runs a script in a predefined path.

 So the question is: given a username, how do I get the homedir?

 I have found pw usershow user1 will return a line from the passwd
 file, but that needs to be split chewed, and spit out. Seems awk can do
 it but I have no clue.

In addition with the other suggestions, an sh(1)-only sollution is this:

$ username=smmsp
$ eval homedir=~${username}
$ echo $homedir
/var/spool/clientmqueue


 Thanks, Erik

 PS: Yes, I know, I could just create a perl script - but this time I
 want to do it all using the tools in base.

That's very basy, isn't it?

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