-   Linux - Newbie (
-   -   Environment variable question (

deeneyc09 04-01-2011 12:20 PM

Environment variable question
Hey guys,

I'm trying to make an environmental variable RPMS that will resolve to a website. I know I have to make the changes in .bash_profile, but all the things I try don't seem to want to work.

I've tried:


or simply just making the variable itself


The second one made a variable just fine, but when I attempted to run this command:

rpm -ihv $RPMS/caching-nameserver*

It was giving me problems.

Any ideas?

kirukan 04-01-2011 12:42 PM

If you need to add a env path, it should something like this,

export PATH
Refer the following

catkin 04-01-2011 12:44 PM


Originally Posted by deeneyc09 (Post 4310914)
Any ideas?

Should have been RPMS=ftp://rha-server/pub/os/rhel5/Server/

David the H. 04-01-2011 12:45 PM

What kind of problems? The command looks like it should work to me, barring this:

$RPMS= shouldn't work, as you can't have $ when setting a variable. Perhaps it's jut a typo in your post though.

If you want your variable to be visible inside scripts and subshells, however, you'll also have to export it.

export RPMS=ftp://rha-server/pub/os/rhel5/Server/
Also, don't use PATH as a variable name. It's a reserved environment variable, one of the most important, and if you change it you'll lose the ability to run any commands without using the full path to the executable.

deeneyc09 04-01-2011 12:48 PM

I found that webpage too, but it's still giving me a:

error: file not found by glob: /caching-server*

Does that mean the path is successful, it's just the glob that's messing it up? I tried to take the wild card out, but it gave me the same error.

David the H. 04-02-2011 03:30 PM

Try echoing the line to see exactly what command the shell is trying to run:

echo rpm -ihv $RPMS/caching-nameserver*
It looks to me like the RPMS variable is turning up as empty. Note how the error message doesn't have a prefix attached.

When the shell does globbing, it first tries to match the given pattern with any existing filenames and, if any are found, replaces the string with them. If it doesn't find anything, then it passes the string literally to the command.

In this case, the string "/caching-nameserver*" means the shell is looking for filenames beginning with that string, like "/caching-nameserver-foo", isn't finding anything like that, and giving the literal string to rpm, which errors out on it.

This is probably mostly because the variable isn't being set properly. But also, is "caching-nameserver" part of the filenames you want to match, or is it a directory name? Perhaps you want to use "cashing-nameserver/*" instead?

It may help more if you can give us some more background on what you're trying to accomplish.

Can you show us the exact series of commands you're trying to run here? And the commands you actually want it to run? It should be something like this:

export RPMS=ftp://rha-server/pub/os/rhel5/Server
rpm -ihv $RPMS/caching-nameserver/*

(Notice, I made an error in my last post, which I've corrected above.)

Finally, please use [code][/code] tags around any code you post, to preserve formatting and to improve readability.

Edit: actually, I'm wondering now--I doubt very much that you can do globbing like this. Globbing is done by the shell, which only does local file-tree matching and string substitution. The ftp lookup is done by rpm, after the globbing is completed. So trying to use "*" to match multiple files is probably no good, unless rpm has it's own ability to glob over ftp.

All times are GMT -5. The time now is 01:31 AM.