Re: shell variables

From: Walter Spector (w6ws_xthisoutx_at_earthlink.net)
Date: 02/08/05


Date: Tue, 08 Feb 2005 05:10:25 GMT

gtg531e wrote:
>
> Unfortunately It can not read shell variables
> $LINES and $COLUMNS...
> What Is wrong?

Try 'export'ing them. At least on my machine, the shell doesn't export
them by default. If an environment variable is unavailable, the ierror
arg should return EINVAL.

Here is a simple test program which works on my home machine (homegrown
version of PXF running under cygwin):

      program testpxf
#if defined (F90CHECK)
#if defined (__INTEL_COMPILER)
      use ifposix
#else
      use pxf_definitions
#endif
#endif
      implicit none

      integer :: nvars
      parameter (nvars=4)

      character(32) :: vars(nvars)
      data vars /"USER", "HISTSIZE", "LINES", "COLUMNS"/

      character(32) :: result
      integer :: lena, lenb
      integer :: i, errno
      logical :: pass

! Get values for desired variables

      pass = .true.
      do, i=1,nvars
          lena = len_trim (vars(i))
          print *, 'Testing: ', vars(i)(:lena)
          call pxfgetenv (vars(i), lena, result, lenb, errno)
          if (errno /= 0) then
              call warn ('pxfgetenv', errno)
              pass = .false.
          end if
          print *, vars(i)(:lena), '=', result(:lenb)
      end do

      if (pass) then
          print *, 'PASS'
      else
          print *, 'FAIL'
      end if

      end

(Subroutine warn not included. But basically does a 'perror' operation.)

When I run this in a 'new' shell, I get:

$ getenv_test
 Testing: USER
 USER=wws
 Testing: HISTSIZE
 WARN: pxfgetenv, Invalid argument
 HISTSIZE=
 Testing: LINES
 WARN: pxfgetenv, Invalid argument
 LINES=
 Testing: COLUMNS
 WARN: pxfgetenv, Invalid argument
 COLUMNS=
 FAIL
$

However if I then try:

$ export LINES COLUMNS HISTSIZE
$ getenv_test
 Testing: USER
 USER=wws
 Testing: HISTSIZE
 HISTSIZE=500
 Testing: LINES
 LINES=65
 Testing: COLUMNS
 COLUMNS=140
 PASS
$

BTW, since you are using the Intel compiler, be sure to use the latest
compiler version you can lay your hands on...

Walt
-...-
Walt Spector
(w6ws at earthlink dot net)



Relevant Pages

  • Re: Console redirected to COM1
    ... >>to use it for the shell. ... debug printing and load the serial driver for it. ... This is what I get on boot on COM1. ... how I got an invalid handle. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: root shell
    ... >was invalid. ... >some workaround for things like this? ... If a non-root user could change root's shell to an arbitrary value ...
    (comp.unix.solaris)
  • Re: handling perl string containing @ and $ with system function
    ... The simplest way would be to bypass the shell: ... perldoc -f system ... (remove .invalid and reverse each component for email address) ...
    (comp.lang.perl.misc)
  • Re: How to know whether certain files was soft linked?
    ... then the link_a will be invalid. ... from the OS or shell. ... if any of them are a soft link to a. ... Chris Mattern ...
    (comp.unix.shell)
  • rlogin TIOCFLUSH problems
    ... I am getting the following problem during rlogin sessions. ... it prints "ioctl TIOCFLUSH: Invalid arguments". ... Whenever I start a new shell, or exit from a shell, it just waits ...
    (comp.unix.solaris)