On Mon, 16 Nov 2009, Devon McCormick wrote:
> Henry -
>
> This sounds like a different but similar problem I have when I run my
> backups: I want to name my backup directory differently according to the
> machine on which I'm running.
>
> I use my own "whoami", which simply invokes the OS version of this command
> and parses the result like this:
>
> whoami=: 3 : 0
> sess=. spawn 'net config workstation'
> sess=. dsp&.><;._1 LF,sess-.CR NB. Vec of lines
> sess=. ><;._1&.> ' ',&.>,sess NB. Mat of words
> strs=. 'COMPUTER';<'USER' NB. Strings to key on
> wh=. (<toupper&.>0{"1 sess)e.&.> <&.>strs NB. Which lines start with
> strings
> wh=. ;b2i&.>(<(toupper&.>1{"1 sess)e. <'NAME')*.&.>wh
> wh{2{"1 sess
> NB.EG 'machine userid'=. whoami ''
> )
> whoami ''
> +--------------+---------------+
> |\\NY0193FF51XX|devon_mccormick|
> +--------------+---------------+
>
> I can then use the machine name to customize the target name.
Will that be over-skilled? 2!:5 'computername' and 'username' should
return similar information. Also 1!:43'' should return the posix pwd.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm