LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-04-2006, 08:14 AM   #1
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Rep: Reputation: 15
SED command problem


Hi,

I was installing frontpage on centos 3.6 and it works fine. But when I try to run same Shell script on Centos 4.3 it doesn't.

The reason for it is

/usr/sbin/apachectl -v | sed 's%^.*Apache/\([0-9\.]*\).*%\1%' | head -1

when I run this command in Centos 3.6 it give me output as My Apache Version (i.e. 2.0.46)

but on Centos it doesn't return any thing where as it should return 2.0.52 (my apache version )

Any idea how to edit this command to pick value as I never work with sed or awk

Thanks
 
Old 07-04-2006, 08:23 AM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Maybe you should post the first line of output from "/usr/sbin/apachectl -v".
 
Old 07-04-2006, 08:28 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Code:
# apache2ctl -v
Server version: Apache/2.2.0
Server built:   May  2 2006 08:51:26

apache2ctl -v | sed  -n '1s/^.*Apache\/\([0-9\.]*\)$/\1/p'
2.2.0
 
Old 07-04-2006, 08:28 AM   #4
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Does apachectl -v even give you the version number, mine doesn't.

Try httpd -v | with-your-sed-script This worked on my machine.
 
Old 07-04-2006, 11:47 PM   #5
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Original Poster
Rep: Reputation: 15
Hi,

Sometime life is what you never thing it off ..

Thanks vls for solution ...

I never imagine that output of httpd -v is different from /usr/sbin/apachectl -v in any way specially when i do this

Code:
[root@DS00255 ~]# /usr/sbin/apachectl -v
Server version: Apache/2.0.52
Server built:   Oct  7 2005 06:37:35
Code:
[root@DS00255 ~]# httpd -v
Server version: Apache/2.0.52
Server built:   Oct  7 2005 06:37:35
Not a single space difference in output but yes

Code:
[root@DS00255 ~]# /usr/sbin/apachectl -v | sed 's%^.*Apache/\([0-9\.]*\).*%\1%' | head -1
return nothing and

Code:
[root@DS00255 ~]# httpd -v | sed 's%^.*Apache/\([0-9\.]*\).*%\1%' | head -1
2.0.52
Does the work ..

Though my problem is solved but any reason of this difference ?
 
Old 07-05-2006, 05:20 AM   #6
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Maybe there's some invisible difference? Try piping the ouput of both commands through "hexdump -c".
 
Old 07-05-2006, 11:48 PM   #7
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Original Poster
Rep: Reputation: 15
Hi,

I guess i don't know exact use of hexdump ...but seems I go my answer anyways

I run these commands
hexdump -c </usr/sbin/httpd -v
hexdump -c </usr/sbin/apachectl -v

And they output totally different from each other and what I got from them without hexdump ...
 
Old 07-06-2006, 02:55 AM   #8
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Talking

Quote:
Originally Posted by vikasumit
And they output totally different from each other
No doubt about that, you're comparing the binary code of two different programs. Try the following instead:
Code:
/usr/sbin/httpd -v | hexdump -c
/usr/sbin/apachectl -v | hexdump -c
BTW, I realized that I also have these programs installed (or ar least something called /usr/sbin/apache2ctl). They return the same information here, and both work with your sed command.
 
Old 07-06-2006, 12:33 PM   #9
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Quote:
Originally Posted by spirit receiver
No doubt about that, you're comparing the binary code of two different programs. Try the following instead:
Code:
/usr/sbin/httpd -v | hexdump -c
/usr/sbin/apachectl -v | hexdump -c
BTW, I realized that I also have these programs installed (or ar least something called /usr/sbin/apache2ctl). They return the same information here, and both work with your sed command.
apachectl is just a shell script wrapper around httpd.
Why the output would come out different called either way is beyond me.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command help... Pete.Hanson@jacobs.c Programming 8 06-02-2006 05:53 PM
problem with sed command LFS 6.0 obsidianblackha Linux From Scratch 6 12-07-2004 10:31 AM
bash Problem with "sed" command blubbfish Linux - Newbie 3 06-01-2004 10:14 AM
sed Command linuxdev Linux - Newbie 3 02-09-2004 11:27 AM
sed command kwigibo Linux - General 3 04-21-2002 04:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:16 PM.

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