Find the answer to your Linux question:
Results 1 to 4 of 4
Hi! I'm newbie in Linux & Scripting. I have a script file: # # print prompt settings # clear echo "Prompt Settings: $PS1" echo "Number of lines on the screen: ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    2

    Exclamation Need help in printing System variables: $PS1, $LINES, $COLUMNS

    Hi!

    I'm newbie in Linux & Scripting. I have a script file:
    #
    # print prompt settings
    #
    clear
    echo "Prompt Settings: $PS1"
    echo "Number of lines on the screen: $LINES"
    echo "Number of columns on the screen: $COLUMNS"
    exit 0

    But I don't know I can't print out the values of $PS1, $LINES, $COLUMNS.

    Please help me
    Thank you.

  2. #2
    Linux Newbie
    Join Date
    Apr 2007
    Posts
    119
    Look up a "scripting howto" or something similar such as this.

  3. #3
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    I assume you ran the script with either:

    ./script.sh

    or

    sh script.sh

    Problem here is that a child process is created to run the script and those system variables don't exist in child processes since they're not needed. You'd have to run it in the current shell process which is done with:

    source script.sh

    WARNING: You're 'exit 0' command will log you off. Better to comment that out first.

  4. #4
    Just Joined!
    Join Date
    Jul 2010
    Posts
    2
    Quote Originally Posted by lomcevak View Post
    I assume you ran the script with either:

    ./script.sh

    or

    sh script.sh

    Problem here is that a child process is created to run the script and those system variables don't exist in child processes since they're not needed. You'd have to run it in the current shell process which is done with:

    source script.sh

    WARNING: You're 'exit 0' command will log you off. Better to comment that out first.
    Thanks lomcevak very much! I run the code successful use your instructions.
    Thaks markcole for a good book.

Posting Permissions

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