setenv: Variable name must contain alphanumeric characters
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
# --- 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
~
~
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...
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.
# --- 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.
Last edited by Habitual; 08-03-2016 at 09:05 AM.
Reason: added alias ~ cd ~
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.
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.
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!
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.
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.