two more questions

This is a discussion on two more questions within the Linux Programming forums, part of the Platform Specific Boards category; 1: What exactly is a Shadow Password? I know that when using a setuid program in the example of a ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    11

    two more questions

    1: What exactly is a Shadow Password?
    I know that when using a setuid program in the example of a program to allow a user to change their own password, it changes the contents of /etc/passwd and /etc/shadow so what is the shadow password exactly?

    2: say I have a script like

    foreach arg (*)
    if (-d $arg)
    echo $arg
    endif
    end

    which lists all directory files under the current working directory, is that correct? and if so how would it differ if I wanted it to list all file names under a directory? what about just executable files?
    Would this script differ if I was using bash instead of tcsh?

    Thats my final question and thank you for your time

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    11
    can I also just add, what would your write for a script that is to list all symbolic links under your home directory if the command line argument lnk exists

    heres what I would think:

    foreach arg (argv[*])
    if (arg == "lnk")

    and then somehow print out just symbolic links if any, would that just be: echo -l

    ???

    Thanks

  3. #3
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    Bash has not foreach.
    This lists all directories in current directory:
    Code:
    for arg in *; do
        if [ -d $arg ]; then
            echo $arg;
        fi;
    done
    If you want to list symbolic links, use -L instead of -d. See man test for all of the parameters.
    Note that [ something ] is similar to test something.
    Last edited by raimo; 07-16-2002 at 06:01 AM.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    11
    Thanks
    If I was to have the shell script run only when the command line argument "something" is entered
    would I do it like this for tcsh:

    if (arg == "something") then
    cd $argv
    foreach arg (*)
    echo $arg
    endif
    end

  5. #5
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    Did you want to check every argument and bash or tcsh?
    Code:
    #!/usr/bin/env tcsh
    foreach arg ($argv)
      if ($arg == "something") then
        echo "something entered as an argument"
        break
      endif
    end
    Code:
    #!/usr/bin/env bash
    for arg in $*
    do
      if [ $arg == "something" ];then
        echo "something entered as an argument"
        break
      fi
    done
    I just noticed your first queston. /etc/shadow is a separate file from /etc/passwd and normal user has no reading permission to it unlike to /etc/passwd. Passwords are now stored there using some not-so-secure des encryption. That is why only root has right to read that file.
    Last edited by raimo; 07-17-2002 at 05:37 AM.
    I am not using Dev-C++.
    #!/usr/bin/env python
    import sys;file=open(sys.argv[0]);print file.read();file.close()

  6. #6
    Registered User
    Join Date
    May 2002
    Posts
    11
    Thank you so much, I am studying for an exam and these were a few specifics I was still unclear on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 09:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 06:36 AM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 08:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 08:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21