Tag Archives: CN

Using sed Command To parse output

By mnassiri

Hi
I have the following output and Ineed to get the variable that is assigned to CN in each line. I have access to SED utility. Can anyone help please?

Regards

“CN=BIS Helpdesk Mailbox_SendAs,OU=ExchangeShareMailboxesACL,OU=Groups,DC=ad,DC=btmna,DC=com”
“CN=BIS Helpdesk Mailbox_FullAccess,OU=ExchangeShareMailboxesACL,OU=Groups,DC=ad,DC=btmna,DC=com”
“CN=CPM Mailbox_SendAs,OU=ExchangeShareMailboxesACL,OU=Groups,DC=ad,DC=btmna,DC=com”
“CN=CPM Mailbox_FullAccess,OU=ExchangeShareMailboxesACL,OU=Groups,DC=ad,DC=btmna,DC=com”
“CN=SF Mailbox_SendAs,OU=ExchangeShareMailboxesACL,OU=Groups,DC=ad,DC=btmna,DC=com”
“CN=SF Mailbox_FullAccess,OU=ExchangeShareMailboxesACL,OU=Groups,DC=ad,DC=btmna,DC=com”

I need to get the name of the mail box indicated after the CN
For example: I need to ge this out put from line one
BIS Helpdesk Mailbox_SendAs

So anything after the CN= until the ,
The line starts with CN= and the text I’m interest in is between CN= and
the next occfurance of the , Comma

I’m using SED command with these options

Usage: sed [OPTION]… {script-only-if-no-other-script} [input-file]…
-n, –quiet, –silent
suppress automatic printing of pattern space
-e script, –expression=script
add the script to the commands to be executed
-f script-file, –file=script-file
add the contents of script-file to the commands to be ex
-i[suffix], –in-place[=suffix]
edit files in place (makes backup if extension supplied)
-l N, –line-length=N
specify the desired line-wrap length for the `l’ command
-r, –regexp-extended
use extended regular expressions in the script.
-s, –separate
consider files as separate rather than as a single conti
long stream.
–text switch to text mode
-u, –unbuffered
load minimal amounts of data from the input files and fl
the output buffers more often
–help display this help and exit
-V, –version output version information and exit
If no -e, –expression, -f, or –file option is given, …read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Apache virtual host config vs global config problem

By freebird8z

Hi folks,

I am trying to configure Apache webserver and also a virtual host inside this webserver.

For Global server config: /var/www/html/index.html
For virtual host config: /var/www/virtual/index.html

Both client10 & www10 are pointing to 192.168.122.10 IP address.

BUT, MY Global webserver is also now pointing to virtual host’s home page. I am not sure how to prevent this. Can anyone help/advice to fix it?

thanks.

Code:

[root@client10 conf]# cat httpd.conf | egrep -v "^$|#|^BrowserMatch|^AddLanguage|^LoadModule|^AddIcon"
ServerTokens OS
ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 60
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15

StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000

StartServers 4
MaxClients 300
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0

Listen 192.168.122.10:80
Include conf.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
ServerName client10.example.com:80
UseCanonicalName Off
DocumentRoot "/var/www/html"

Options FollowSymLinks
AllowOverride None

Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Order deny,allow
Allow from 127.0.0.1

UserDir disabled

DirectoryIndex index.html index.html.var
AccessFileName .htaccess

Order allow,deny
Deny from all
Satisfy All

TypesConfig /etc/mime.types
DefaultType text/plain

MIMEMagicFile conf/magic

HostnameLookups Off
ErrorLog logs/error_log
LogLevel warn
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access_log combined
ServerSignature On
Alias /icons/ "/var/www/icons/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

DAVLockDB /var/lib/dav/lockdb

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

AllowOverride None
Options None
Order allow,deny
Allow from all

IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8
DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
ForceLanguagePriority Prefer Fallback
AddDefaultCharset UTF-8
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
AddHandler type-map var
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Alias /error/ "/var/www/error/"

AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en es de fr
ForceLanguagePriority Prefer Fallback

NameVirtualHost 192.168.122.10

ServerAdmin tony@www10.example.com
DocumentRoot /var/www/virtual
ServerName www10.example.com
ErrorLog logs/www10.example.com-error_log
CustomLog logs/www10.example.com-access_log common


…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Perl to extract ssl certs from xml file

By jhamaks

HI Guys,

I’m a newbie in perl. I have a task where there’s an xml file which has ssl certs stored in it. The file would look like –

Now, i want to extract each of the SSL certs from this file and store them at some location on the same machine. The cert file to be saved on the disk should have the filename as the common name(CN) of that ssl cert.

I know that using openssl cmd i should get the common name of the cert file, but how to get the common name(CN) from the ssl string (as you see above) instead of file?

Can someone help with any regex to extact the ssl cert from the file of above format ? I guess the tag “” at the end of the string can be used to create the regex ?
Please help.

Thank you.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums