Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, as Newbie i have a stupid question that i am sure everybody but me, knows the answer. Why the variable $LINE, if echoed from command line, gives the correct ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    5

    Stupd question about environment variable

    Hi, as Newbie i have a stupid question that i am sure everybody but me, knows the answer.
    Why the variable $LINE, if echoed from command line, gives the correct number of lines of the screen, but if echoed within a script it gives a blank value?
    Thank you
    Gabe

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    My guess is the subshell that a script is executed in doesn't have any real lines to it.

  3. #3
    Just Joined!
    Join Date
    Jun 2007
    Posts
    5
    Quote Originally Posted by likwid View Post
    My guess is the subshell that a script is executed in doesn't have any real lines to it.

    Is there a way to get the resolution of the screen from the script?
    Perhaps with tput...

  4. #4
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    xrandr, if you have it.

  5. #5
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Have you tried exporting the variable so it's inherited by subshells?

  6. #6
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    This would work, however I'm not sure how viable of a solution it is.

  7. #7
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Well, the problem Lele wanted to solve was how to get the value of the LINE var in a subshell, so if it works, it's viable! Whether it's the solution to the real problem, of course ....

  8. #8
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Well, running export LINES; export COLUMNS before running the script everytime would kind of not be cool. You could add -i as an argument to bash at the top of your script, that would probably give you LINES and COLUMNS.

Posting Permissions

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