Berkeley CSUA MOTD:Entry 32883
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2018/11/15 [General] UID:1000 Activity:popular
11/15   

2004/8/13 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:32883 Activity:nil
8/12    I am not a techie but I am trying to learn some perl to do
        some text manipulation for my research.  I am having trouble
        with hashes.  Can someone give me an example of how to read
        in something like the password file (say, user, directory, shell)
        into a hash?
        \_ The question belies a slight misunderstanding of hashes.  A hash
           is a simple set of key value pairs, so reading a password file
           in would require a bit of thought to the structure.  You could
           make the key be uid and the value be a pointer to an array of
           the passwd line, i.e. (username,pw,uid,gid,gcos,hdir,shell).
           You could alternately key on username.  You could make an array
           of hash references where each array member is like
             username => 'root',
             pw => '*',
             uid => 0,
             gid => 0,
           etc.  But using a single 1-dimensional hash on something like
           an entire passwd file would yield you the data from the last
           line in the file.
           \_What would be the right structure to use to read in the
             whole password table and hold it in a structure so I could
             refer to some arbitrary piece of data like "the shell of
             user user1"?  Like if I wanted to merge the encrypted password
             from the shadow file with the login and shell fields from the
             password file?  Thanks for your explanation.
             \_ Now that you could do with a hash, but easier would be to use
                (getpwnam('user1'))[8] to get the shell.  But to do this for
                the whole passwd file (as an example) would be
                  open PW,'/etc/passwd';
                  my %shells;
                  foreach my $pwentry (<PW>) {
                    chomp $pwentry;
                    ($name,$shell) = (split /:/,$pwentry)[0,6];
                    $shells{$name} = $shell;
                  }
                  close PW;
                Oh wait.  I didn't catch the part about shadow password, but
                this should give you an idea of where to start.
ERROR, url_link recursive (eces.Colorado.EDU/secure/mindterm2) 2018/11/15 [General] UID:1000 Activity:popular
11/15   

You may also be interested in these entries...
2012/8/26-11/7 [Computer/SW/Security] UID:54465 Activity:nil
8/26    Poll: how many of you pub/priv key users: 1) use private keys that
        are not password protected 2) password protect your private keys
        but don't use ssh-agent 3) use ssh-agent:
        1) .
        2) ..
        3) ...
	...
2012/8/29-11/7 [Computer/SW/Security] UID:54467 Activity:nil
8/29    There was once a CSUA web page which runs an SSH client for logging
        on to soda.  Does that page still exist?  Can someone remind me of the
        URL please?  Thx.
        \_ what do you mean? instruction on how to ssh into soda?
           \_ No I think he means the ssh applet, which, iirc, was an applet
              that implemented an ssh v1 client.  I think this page went away
	...
2012/9/20-11/7 [Finance/Investment, Computer/SW/Unix] UID:54482 Activity:nil
9/20    How do I change my shell? chsh says "Cannot change ID to root."
        \_ /usr/bin/chsh does not have the SUID permission set. Without
           being set, it does not successfully change a user's shell.
           Typical newbie sys admin (on soda)
           \_ Actually, it does: -rwsr-xr-x 1 root root 37552 Feb 15  2011 /usr/bin/chsh
	...
2012/9/24-11/7 [Computer/SW/Languages, Computer/SW/Unix] UID:54484 Activity:nil
9/24    How come changing my shell using ldapmodify (chsh doesn't work) doesn't
        work either? ldapsearch and getent show the new shell but I still get
        the old shell on login.
        \_ Scratch that, it magically took my new shell now. WTF?
           \_ probably nscd(8)
	...
2012/4/27-6/4 [Computer/SW/Languages/Misc, Computer/SW/Unix] UID:54372 Activity:nil
4/27    I wrote a little shell script to collect iostat data:
        #!/bin/bash
        DATE=`date +%m%d`
        DATADIR=/var/tmp/user
        OUTPUTFILE=$DATADIR/$DATE.out
        while true
	...
2012/5/8-6/4 [Computer/SW/Unix] UID:54383 Activity:nil
5/8     Hello everyone!  This is Josh Hawn, CSUA Tech VP for Spring 2012.
        About 2 weeks ago, someone brought to my attention that our script
        to periodically merge /etc/motd.public into /etc/motd wasn't
        running.  When I looked into it, the cron daemon was running, but
        there hadn't been any root activity in the log since April 7th.  I
        looked into it for a while, but got lost in other things I was
	...
2011/10/26-12/6 [Computer/SW/Unix] UID:54202 Activity:nil
10/24  What's an easy way to see if say column 3 of a file matches a list of
       expressions in a file? Basically I want to combine "grep -f <file>"
       to store the patterns and awk's $3 ~ /(AAA|BBB|CCC)/ ... I realize
       I can do this with "egrep -f " and use regexp instead of strings, but
       was wondering if there was some magic way to do this.
       \_ UNIX has no magic. Make a shell script to produce the ask or egrep
	...
2011/4/27-7/30 [Computer/SW/Unix, Computer/SW/Security] UID:54096 Activity:nil
4/28    Will wall be fixed?   - jsl
        \_ What's wall?
           \_ An anachronism from a bygone era, when computers were hard to
              comeby, the dorms didn't have net, there was no airbears, and
              when phones didn't come standard with twitter or sms.
           \_ A non useful implementation of twitter.
	...
2011/5/19-7/30 [Computer/SW/Security] UID:54110 Activity:nil
5/19    Uh, is anyone still using this? Please mark here if you post and
        haven't added this yet. I'll start:
        \_ person k
        \_ ausman, I check in about once a week.
        \_ erikred, twice a week or so.
        \_ mehlhaff, I login when I actually own my home directory instead of
	...
2011/5/19-7/13 [Computer/SW/Languages/Misc] UID:54115 Activity:nil
5/19    If script A runs, and calls script B ..... is it possible for me to exit\
        script A based on results of script B and not continue?
        \_ assume any shell
        \_ Yes.
           \_ without passing the result to some stupid temp file?
              \_ It sounds like you want "scriptb || exit", which will run
	...