Find the answer to your Linux question:
Page 4 of 4 FirstFirst 1 2 3 4
Results 31 to 34 of 34
Hi thanks for help again. What i want to do is ask username and print the usernames home directory path. How do i do that? thanks...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #31
    Just Joined!
    Join Date
    Aug 2006
    Posts
    16

    scripting


    Hi thanks for help again. What i want to do is ask username and print the usernames home directory path. How do i do that?

    thanks

  2. #32
    Just Joined!
    Join Date
    Aug 2006
    Posts
    16

    scripting

    Hi there, why doesnt this script work properly?

    thanks

    Code:
    #!/bin/sh
    clear
    
    echo "Script File Name: $0 "
    echo "The arguments are: "
    for a in $*; do
    echo $a
    done
    
    if [ $# -lt 2 ] ; then
    echo "New filename missing"
    fi
    
    clear
    
    echo "Enter name of original file"
    read filename
    if [ $filename = $1 ] ; then
    echo "The filename you entered is $filename"
    fi
    
    clear
    
    echo "Enter the new name for the file"
    read filename 2
    if [ $filename2 = $2 ] ; then
    echo "The filename you entered is $filename2"
    fi
    
    echo "Do you want to overwrite the first filename? (y/n)?"
    read verdict
    if [ "$verdict" = "y" ] ; then
    echo "$filename2 >> $filename"
    mv $filename2 $filename
    elif [ "$verdict" = "n" ] ; then
    echo "You have chosen not to overwrite. The script will now exit"
    exit 0
    fi

  3. #33
    Banned jan1024188's Avatar
    Join Date
    Jul 2006
    Location
    EU, SLOVENIA
    Posts
    1,549
    that should work
    Code:
    #!/bin/sh
    clear
    
    echo "Script File Name: $0 "
    echo "The arguments are: "
    for a in $*; do
    echo $a
    done
    
    if [ $# -lt 2 ] ; then
    echo "New filename missing"
    fi
    
    clear
    
    echo "Enter name of original file"
    read filename
    if [ "$filename" = "$1" ]; then
    echo "The filename you entered is $filename"
    fi
    
    clear
    
    echo "Enter the new name for the file"
    read filename2
    if [ "$filename2" = "$2" ]; then
    echo "The filename you entered is $filename2"
    fi
    
    echo "Do you want to overwrite the first filename? (y/n)?"
    read verdict
    if [ "$verdict" = "y" ]; then
    echo "$filename2 >> $filename"
    mv $filename2 $filename
    elif [ "$verdict" = "n" ]; then
    echo "You have chosen not to overwrite. The script will now exit"
    exit 0
    fi
    you are making the same mistakes all the time

    if [ $filename = $1 ] ; then

    here should be quotas
    if [ "$filename" = "$1" ] ; then
    and no space between ] and ; would be appriciated
    if [ "$filename" = "$1" ]; then

    you posted this script ten times!!!!!

  4. $spacer_open
    $spacer_close
  5. #34
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    hi krist !!

    i dont understand......... we are solving your porblems again n again but you are not studying or understanding these a bit ....whats going on..... ????

    i am writing again..... we are not going to solve your problems like this.....
    no more help form here now......... and no more silly questions.....
    read this thread again, each and every given solution....... buy a good book or study the tutorials i linked in earlier thread.................

    <=== { casper } ===>
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

Page 4 of 4 FirstFirst 1 2 3 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •