LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2007, 12:22 AM   #1
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Rep: Reputation: 30
bash script


hi all
i would like to know the current version of mozilla and where is it...
i triese this
Code:
#!/bin/bashk=" "
i=`rpm -ql mozilla | grep /usr/lib/mozilla- | tail -1 | cut -d/ -f4`
echo $i
path=`whereis $i |cut -d" " -f2`
pathname=$(path)
echo $pathname
how to use out put of "i" in "path" as input.
i wanna out put like this
Quote:
for echo $i
mozilla-1.7.13

and
for echo $pathname
/usr/lib/mozilla-1.7.13
how to get this..
please help me

thank you in advance
 
Old 07-28-2007, 01:10 AM   #2
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 297

Rep: Reputation: 49
Instead of cluttering your PATH with every bit of software you want to run (as you would in Windows), the preferred way is to create a link in one of the standard bin directories, e.g.:
Code:
ln -s /usr/lib/mozilla-1.7.13/mozilla /usr/bin/mozilla
(or whatever the mozilla binary is called...)
 
Old 07-28-2007, 01:29 AM   #3
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by rupertwh
Instead of cluttering your PATH with every bit of software you want to run (as you would in Windows), the preferred way is to create a link in one of the standard bin directories, e.g.:
Code:
ln -s /usr/lib/mozilla-1.7.13/mozilla /usr/bin/mozilla
(or whatever the mozilla binary is called...)
no am giving the total output in make file library path..
it will dynamically check the mozilla version and get the perticular ".so" file..

i tried this in make file of the source code
Code:
k=" "
k=`rpm -ql mozilla | grep /usr/lib/mozilla- | tail -1 | cut -d/ -f4`
path=`whereis $k |cut -d" " -f2`
full_path="$path/$i"
i suceeded to get the path but have to implement in make file.help me.


[QUOTE]
phone_LDADD = -L$(HOME)/.g7libs -L${fullpath} -L/usr/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lbapi -lavcodec -lportaudio -lfedoraurl -lgtkembedmoz -lxpcom -lxml2 $(INTLLIBS)
all: all-am
[QUOTE]

after make the souce... the output is like this in the terminal
[QUOTE]
gcc -g -O2 -o phone main.o support.o interface.o callbacks.o -L/root/.fedora -L"ath/" -L/usr/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lbapi -lavcodec -/lportaudio -lfedoraurl -lgtkembedmoz -lxpcom -lxml2
[QUOTE]

actually it will be like this( i wanna this in terminal while making the sorce code)
Quote:
gcc -g -O2 -o phone main.o support.o interface.o callbacks.o -L/root/.fedora -L/usr/lib/mozilla-1.7.13 -L/usr/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lbapi -lavcodec -lportaudio -lfedoraurl -lgtkembedmoz -lxpcom -lxml2
please observe the bold text.

can you please help me

thank you in advance
 
Old 07-28-2007, 04:06 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you know enough of the library name you need, couldn't you use locate instead.

I don't have the mozilla browser installed. So I'll use another example:
mozlib=$(dirname $(locate libxaa.so))

Then you could use this:
Code:
gcc -g -O2 -o phone main.o support.o interface.o callbacks.o -L/root/.fedora -L${mozlib} ...
If you are writing a makefile, You could try using something like:
mozlib := $(shell $(dirname $(locate libxaa.so)))
 
Old 07-28-2007, 05:18 AM   #5
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by jschiwal
If you know enough of the library name you need, couldn't you use locate instead.

I don't have the mozilla browser installed. So I'll use another example:
mozlib=$(dirname $(locate libxaa.so))

Then you could use this:
Code:
gcc -g -O2 -o phone main.o support.o interface.o callbacks.o -L/root/.fedora -L${mozlib} ...
If you are writing a makefile, You could try using something like:
mozlib := $(shell $(dirname $(locate libxaa.so)))
great work..
mozlib := $(shell $(dirname $(locate libxaa.so)))
the above line will help me more top write in make file am very near to get the solution for it.....


but in some machine mozilla path will bw varied..
ex: in fedora it is /usr/lib/
in suse /opt/
....like that..

so that i tried this in make file...
Code:
k=" "
#k=`rpm -ql mozilla | grep /usr/lib/mozilla- | tail -1 | cut -d/ -f4`
k=`mozilla -V | sed -e 's/\([^,]*\),.*/\L\1/' -e 's/ /-/'`
path=`whereis $k |cut -d" " -f2`
#full_path="$path/$i"
full_path="$path"
#mozlib := $(shell $(dirname $(locate libxaa.so)))
mozlib := $(shell $(path))
and at the library
Code:
gcc -g -O2 -o phone main.o support.o interface.o callbacks.o -L/root/.fedora -L${mozlib} ...
now the output at the terminal is
Code:
gcc -g -O2 -o phone main.o support.o interface.o callbacks.o -L/root/.fedora -Lmozilla-1.7.13 ......
i wud like to insert all the path(not manually becouse let us say i dont know where the mozilla-1.7.13 is) in this "mozlib := $(shell $(path))"

do you know..full_path contains solution but it did not working...
what i have to do....

please help me .. it is near to get solution

thank you in advance
 
Old 07-28-2007, 05:43 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I'm not certain I get what your question is. Maybe you want to get the directory name from the full pathname. You can use the "dirname" command.

example:
Code:
mozdir=$(dirname $(locate -r '/usr/lib.*libplain\.so\.' | head -n 1))
Notice that you can embed one $( .. ) inside another. That is one reason the using $() is better than using backticks.

Again, I tested this on a non-mozilla library file because I don't have it installed myself.
 
Old 07-28-2007, 06:03 AM   #7
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by jschiwal
I'm not certain I get what your question is. Maybe you want to get the directory name from the full pathname. You can use the "dirname" command.

example:
Code:
mozdir=$(dirname $(locate -r '/usr/lib.*libplain\.so\.' | head -n 1))
Notice that you can embed one $( .. ) inside another. That is one reason the using $() is better than using backticks.

Again, I tested this on a non-mozilla library file because I don't have it installed myself.
no..no. not this..
i tried this
Code:
k=" "
k=`mozilla -V | sed -e 's/\([^,]*\),.*/\L\1/' -e 's/ /-/'`
path=`whereis $k |cut -d" " -f2`
mozlib := $(shell $(path))
here "path" contains the total path of the LIBdirectory...i.e
/usr/lib/mozilla-1.7.12
but am getting only
mozilla-1.7.12 in the make file

what i have to do to get /usr/lib/mozilla-1.7.12

thank you in advance
 
Old 07-28-2007, 06:09 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The previous suggestion I made: mozlib := $(shell $(dirname $(locate libxaa.so)))
doesn't work as I thought it would.

You could export the mozlib variable and then run make. Here is an example:
Code:
> unset mozlib
> export mozlib=$(dirname $(locate libxaa.so))
> make
echo mozlib: /usr/lib64/xorg/modules
mozlib: /usr/lib64/xorg/modules
> cat Makefile
all:
        echo mozlib: $(mozlib)
Your makefile could add your variable to what you already have defined in the makefile with a command like:
LIB += $(mozlib)

Code:
cat Makefile

LIB = /usr/local/lib
LIB += $(mozlib)
all:
        echo mozlib: $(mozlib)
        echo LIB:    $(LIB)

> make
echo mozlib: /usr/lib64/xorg/modules
mozlib: /usr/lib64/xorg/modules
echo LIB:    /usr/local/lib /usr/lib64/xorg/modules
LIB: /usr/local/lib /usr/lib64/xorg/modules

Last edited by jschiwal; 07-28-2007 at 06:12 AM.
 
Old 07-28-2007, 06:56 AM   #9
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
sorry it is not working...
mozlib := $(shell $(path))
here you used the word shell,
what is the shell here.
can you please explain about it..
is there any command like shell(in linux script for make file)..

thank you in advance
 
Old 07-28-2007, 07:59 AM   #10
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Reread my last post. I said it didn't work for me either. Then I suggested evaluating the variable outside the Makefile, exporting the variable, and then using the variable in the Makefile.

You might want to read 8.11 in the make info manual for $(shell ..) examples.

Last edited by jschiwal; 07-28-2007 at 08:02 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
[bash] having trouble debugging this bash script. jons Programming 4 02-08-2007 06:51 AM
Bash script hangs upon starting another script in the background masea2 Linux - Software 4 11-13-2006 05:18 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration