LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   setenv: Variable name must contain alphanumeric characters (https://www.linuxquestions.org/questions/linux-software-2/setenv-variable-name-must-contain-alphanumeric-characters-4175585617/)

skathir1 07-27-2016 04:53 AM

setenv: Variable name must contain alphanumeric characters
 
In RHEL 6.7 su - newuser getting following error.

setenv: Variable name must contain alphanumeric characters

It is not getting user .cshrc information

rtmistler 07-27-2016 06:22 AM

And do you know the .cshrc line or variable name set attempt which is causing this? Show the line where the complaint has been given. Typically there's an illegal character in the attempted variable name.

skathir1 07-29-2016 07:46 AM

# --- tcsh settings
set prompt="%B%n@%m%b [%~]# "
set autolist
set autoexpand
set autocorrect
set color
set history=5000
set savehist=5000
set notify
set complete="enhance"
set savehist
set correct=cmd
set autologout=0
set color
set colorcat
# --- Oracle settings
setenv ORACLE_HOME /export/home/oracle/product/12.1.0/db_1
setenv ORACLE_BASE /export/home/oracle
setenv ORACLE_SID mcdb
setenv NLS_LANG AMERICAN_AMERICA.AL32UTF8
setenv LD_LIBRARY_PATH /lib
setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/export/home/oracle/product/12.1.0/db_1/bin:/export/home/oracle/product/12.1.0/db_1/OPatch:/usr/ccs/bin:/usr/ucb
setenv TMP /export/home/oracle/tmp_a/tmp
setenv TMPDIR /export/home/oracle/tmp_a/tmp
setenv SSH_DEBUG 0
setenv IS_CLONE 1
# --- alias
alias ec "env echo -ne "
alias dc cd
alias r rlogin
alias ~ cd ~
alias / cd /
alias more less
alias x \'chmod +x\'
alias cpd \'cp -Rp\'
alias ll \'ls -ltr\'
alias .. \'cd ..\'
alias - less
alias back \'set back=; set old=;cd ; unset back\'
alias s ssh
~
~

jpollard 07-29-2016 10:11 AM

I suspect the line "alias / cd /"; but without a trace with the error message I can't tell; and it could be any of the other special characters used as an alias name.

The problem these (or at least SOME of these) cause is that a shell normally processes the line for substitutions BEFORE they are used to identifies what is to be used as a variable. Thus things like "~" get replaced with the users home directory... then the command processing starts.

I've never seen special characters used as an alias...

skathir1 07-30-2016 02:13 AM

Thanks But it is happening only RHEL 6.7 machine same is working fine in RHEL 6.5.

is there any difference between both version?

jpollard 07-30-2016 05:22 AM

could be a bug fix.

After all, that is why the minor version changes...

Just for testing, you could try copying tcsh from the 6.5 machine and try it out.

I gave up on csh/tcsh a LONG time ago - scripts were much less portable, and bash works better (and gets a LOT more testing). Bash is what gets used for the most.

Habitual 07-30-2016 06:12 AM

Code:

alias - less
alias ~ cd ~

are certainly interesting, to me.

compare to
Code:

su - <newuser>
also try
Code:

\su - <newyuser>
Remove or comment
Code:

# --- alias
alias ec "env echo -ne "
alias dc cd
alias r rlogin
alias ~ cd ~
alias / cd /
alias more less
alias x \'chmod +x\'
alias cpd \'cp -Rp\'
alias ll \'ls -ltr\'
alias .. \'cd ..\'
alias - less
alias back \'set back=; set old=;cd ; unset back\'
alias s ssh

and try the operation again.

skathir1 08-02-2016 02:11 AM

As a root user when i issue command "tcsh" getting same error

setenv: Variable name must contain alphanumeric characters

it is happening only in RHEL 6.7.

please suggest me

rtmistler 08-02-2016 06:46 AM

Quote:

Originally Posted by skathir1 (Post 5584539)
As a root user when i issue command "tcsh" getting same error

setenv: Variable name must contain alphanumeric characters

it is happening only in RHEL 6.7.

please suggest me

There's been a number of suggestions. One which has excellent merit and can be expanded upon is to follow Habitual's recommendation above, but to go further. Comment out everything except the first line. Verify that the first line is OK, then uncomment out the next line, verify that the first and second line are OK, and continue. Eventually you'll figure out which line is causing this problem. Another thing to do here is to enable debug by placing "set -vx" at the top of your script. The final option might be to contact RedHat considering you're using RHEL and that should contain support.

Fishmed 06-28-2017 10:30 AM

Posible Resolution
 
Quote:

Originally Posted by rtmistler (Post 5584602)
There's been a number of suggestions. One which has excellent merit and can be expanded upon is to follow Habitual's recommendation above, but to go further. Comment out everything except the first line. Verify that the first line is OK, then uncomment out the next line, verify that the first and second line are OK, and continue. Eventually you'll figure out which line is causing this problem. Another thing to do here is to enable debug by placing "set -vx" at the top of your script. The final option might be to contact RedHat considering you're using RHEL and that should contain support.

I was moving a script from UNIX to Linux and experienced the error as the OP. In my search for a cause/resolution, I stumbled on this forum/thread. I used the "set -vx" to find the source of my problem. I found that by replacing the "setenv" command with "export", the issue cleared up. I see the script above has several "setenv" commands that may have needed to be replaced. The resulting error message really does not identify the cause.

Thank you rtmistler for your debug tip!

rtmistler 06-28-2017 12:15 PM

Quote:

Originally Posted by Fishmed (Post 5728324)
I was moving a script from UNIX to Linux and experienced the error as the OP. In my search for a cause/resolution, I stumbled on this forum/thread. I used the "set -vx" to find the source of my problem. I found that by replacing the "setenv" command with "export", the issue cleared up. I see the script above has several "setenv" commands that may have needed to be replaced. The resulting error message really does not identify the cause.

Thank you rtmistler for your debug tip!

Hi Fishmed and welcome to LQ! :)

I'm glad the thread was of some help to you. Typically for some bash questions I also recommend my blog on that subject, but see I hadn't here. Either case, it is an old blog which describes a lot about how to debug bash scripts in general. The LQ link for it is here. Happy scripting! :)

Fishmed 06-28-2017 12:27 PM

Quote:

Originally Posted by Fishmed (Post 5728324)
I was moving a script from UNIX to Linux and experienced the error as the OP. In my search for a cause/resolution, I stumbled on this forum/thread. I used the "set -vx" to find the source of my problem. I found that by replacing the "setenv" command with "export", the issue cleared up. I see the script above has several "setenv" commands that may have needed to be replaced. The resulting error message really does not identify the cause.

Thank you rtmistler for your debug tip!

To add to my post. I found that I had to leave the "set -vx" command in place with the other changes for the script to work.

Laserbeak 07-01-2017 03:43 AM

The real csh is notoriously buggy, you shouldn't even be using it. If you're using tcsh, that tried to fix most of the bugs but some were simply unfixable. You really you should be using bash, it is really best shell out there among the commonly used ones. Maybe ksh and zsh etc. are OK but they're not commonly used.

The only reason csh ever got any traction is because it was written by Bill Joy, a cofounder of Sun Microsystems.

jpollard 07-01-2017 05:56 AM

Quote:

Originally Posted by Laserbeak (Post 5729418)
The real csh is notoriously buggy, you shouldn't even be using it. If you're using tcsh, that tried to fix most of the bugs but some were simply unfixable. You really you should be using bash, it is really best shell out there among the commonly used ones. Maybe ksh and zsh etc. are OK but they're not commonly used.

The only reason csh ever got any traction is because it was written by Bill Joy, a cofounder of Sun Microsystems.

I never did like cshell for anything except the history option.

Always used the Bourne shell as that was the only (and still is) portable scripting shell. Bash comes close, but now you have to avoid so many things to make the scripts portable.

pan64 07-01-2017 06:58 AM

would be nice to know the version of tcsh
also you can insert set echo; set verbose to see what's happening (and you will see the lines as they executed).


All times are GMT -5. The time now is 12:48 AM.