LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 04-01-2011, 12:20 PM   #1
deeneyc09
LQ Newbie
 
Registered: Mar 2011
Posts: 14

Rep: Reputation: 0
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:

PATH=$RPMS:ftp://rha-server/pub/os/rhel5/Server/

or simply just making the variable itself

$RPMS=ftp://rha-server/pub/os/rhel5/Server/


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?
 
Old 04-01-2011, 12:42 PM   #2
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,183

Rep: Reputation: 113Reputation: 113
If you need to add a env path, it should something like this,
Quote:
Ex:-
PATH=$PATH:/usr/java/j2sdk1.4.2/bin
export PATH
Refer the following
http://www.rpm.org/max-rpm/s1-rpm-in...g-install.html
 
Old 04-01-2011, 12:44 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,514
Blog Entries: 27

Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
Quote:
Originally Posted by deeneyc09 View Post
$RPMS=ftp://rha-server/pub/os/rhel5/Server/
Any ideas?
Should have been RPMS=ftp://rha-server/pub/os/rhel5/Server/
 
Old 04-01-2011, 12:45 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
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.
Code:
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.

Last edited by David the H.; 04-02-2011 at 03:30 PM. Reason: fixed syntax error
 
Old 04-01-2011, 12:48 PM   #5
deeneyc09
LQ Newbie
 
Registered: Mar 2011
Posts: 14

Original Poster
Rep: Reputation: 0
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.

Last edited by deeneyc09; 04-01-2011 at 12:57 PM.
 
Old 04-02-2011, 03:30 PM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
Try echoing the line to see exactly what command the shell is trying to run:
Code:
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:
Code:
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.

Last edited by David the H.; 04-02-2011 at 03:44 PM. Reason: as stated + rewording
 
  


Reply

Tags
bashprofile, environment variable, ftp, rpm


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
possible environment variable question. nathank000 Linux - Newbie 6 09-06-2007 11:18 PM
Global (shell) environment variable question Seventh Linux - Newbie 1 04-05-2007 03:18 PM
environment variable gamor Linux - Newbie 4 04-30-2005 05:28 PM
Environment Variable salmanucit Linux - Software 2 07-21-2004 02:27 AM
environment variable mimi Linux - Newbie 1 04-10-2002 08:29 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration