<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AIX &#8211; Blog of Kliment Andreev &#8211; A place so I won&#039;t forget things</title>
	<atom:link href="https://blog.andreev.it/category/aix/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.andreev.it</link>
	<description></description>
	<lastBuildDate>Sun, 11 Oct 2020 14:23:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>PowerShell, shell: Remove comments from source (Windows/Linux/BSD)</title>
		<link>https://blog.andreev.it/2016/12/103-norem-utility-remove-comments-source/</link>
					<comments>https://blog.andreev.it/2016/12/103-norem-utility-remove-comments-source/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Wed, 14 Dec 2016 15:53:14 +0000</pubDate>
				<category><![CDATA[AIX]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[OpenBSD]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Unix shell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[remove comments]]></category>
		<category><![CDATA[sh]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=2990</guid>

					<description><![CDATA[norem for Linux/*BSD A small utility written in Bourne shell (compatible with both sh&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><h1>norem for Linux/*BSD</h1>
<p>A small utility written in Bourne shell (compatible with both <strong>sh </strong>and <strong>bash</strong>, which means works without changes on all *BSD/Linux) that strips comments from a source file. E.g. I am too lazy to scroll through <strong>/etc/ssh/sshd_config</strong> file to look for  any valid directives.<br />
Here is <strong>/etc/ssh/sshd_config</strong> on FreeBSD.</p>
<pre class="brush: plain; collapse: true; light: false; title: ; toolbar: true; notranslate">
#       $OpenBSD: sshd_config,v 1.98 2016/02/17 05:29:04 djm Exp $
#       $FreeBSD: releng/10.3/crypto/openssh/sshd_config 296853 2016-03-14 13:05:13Z des $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# Note that some of FreeBSD's defaults differ from OpenBSD's, and
# FreeBSD has a few additional options.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
#Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Ciphers and keying
#RekeyLimit default none

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# Change to yes to enable built-in password authentication.
#PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable PAM authentication
#ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'no' to disable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of &quot;PermitRootLogin without-password&quot;.
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum FreeBSD-20160310

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    /usr/libexec/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server
</pre>
<p>With this utility, I can just do:</p>
<pre class="brush: bash; title: ; notranslate">
norem -f /etc/ssh/sshd_config
</pre>
<p>&#8230; and voila&#8230;You have the meat without the bones.</p>
<pre class="brush: plain; title: ; notranslate">
Subsystem       sftp    /usr/libexec/sftp-server
</pre>
<p>Almost all *nix utilities have &#8220;#&#8221; as a comment, but some languages such as Java and C++ use &#8220;//&#8221; for comments. In this case, we have to run:</p>
<pre class="brush: bash; title: ; notranslate">
norem -f file -c &quot;/&quot;
</pre>
<p>The utility is not smart enough for multi-line comments such as &#8220;/*&#8230;*/&#8221;<br />
Here is the source:</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh

usage()
{
    echo &quot;usage: norem &#x5B;-f file ] | &#x5B;-c char] | &#x5B;-e]] | &#x5B;-h]]&quot;
    echo &quot;Prints a file skipping the lines that start with -c&quot;
    echo &quot;By default empty lines are not printed, use -e yes to include them&quot;
    echo &quot;Kliment Andreev - 2016&quot;
}

if &#x5B; &quot;$#&quot; == &quot;0&quot; ]; then
        usage
        exit 1
fi

while &#x5B; $# -gt 0 ]; do
        key=&quot;$1&quot;

        case $key in
                -f|--file)
                        FILENAME=&quot;$2&quot;
                    shift
                        ;;
        -c|--char)
                        CHARACTER=&quot;$2&quot;
                        shift
                ;;
                -e|--empty)
                EMPTY=&quot;$2&quot;
                shift
                ;;
        *)
                usage
                        exit
                ;;
        esac
        shift
done

if &#x5B; -z &quot;${CHARACTER}&quot; ]; then
        CHARACTER=&quot;#&quot;
fi

if &#x5B; -z &quot;${EMPTY}&quot; ]; then
        cat ${FILENAME} | sed &quot;/^\\${CHARACTER}/d&quot; | awk /./
else
        cat ${FILENAME} |sed &quot;/^\\${CHARACTER}/d&quot;
fi
</pre>
<h1>norem for PowerShell</h1>
<p>The same utility for PowerShell. The input parameters are the same.</p>
<pre class="brush: powershell; title: ; notranslate">
Param(
	&#x5B;string]$fileName,
	&#x5B;string]$char=&quot;#&quot;,
	&#x5B;string]$empty
)

function usage {
    Write-Host &quot;usage: norem &#x5B;-f file ] | &#x5B;-c char] | &#x5B;-e]]&quot;
    Write-Host &quot;Prints a file skipping the lines that start with -c&quot;
    Write-Host &quot;By default empty lines are not printed, use -e yes to include them&quot;
    Write-Host &quot;Kliment Andreev - 2016&quot;
}

if ($psboundparameters.Count -eq 0) {
    usage
    exit
}

if ($empty.ToUpper().Contains(&quot;Y&quot;)) {
    Get-Content $fileName | Where { $_ -notmatch &quot;^&quot; + $char }
}
else {
    Get-Content $fileName | Where { $_ -notmatch &quot;^&quot; + $char } | Where {$_.trim() -ne &quot;&quot;}
}
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2016/12/103-norem-utility-remove-comments-source/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AIX: Remove EMC LUNs/VGs/disks from AIX &#8211; powerpath</title>
		<link>https://blog.andreev.it/2012/01/remove-emc-lunsvgsdisks-from-aix-powerpath/</link>
					<comments>https://blog.andreev.it/2012/01/remove-emc-lunsvgsdisks-from-aix-powerpath/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Wed, 18 Jan 2012 19:40:55 +0000</pubDate>
				<category><![CDATA[AIX]]></category>
		<category><![CDATA[powerpath]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=251</guid>

					<description><![CDATA[I had to remove some EMC drives from an AIX box that were not&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>I had to remove some EMC drives from an AIX box that were not used anymore. I had 5 filesystems, but I’ll describe the procedure for 1 filesystem. The first thing to do is to unmount the filesystems.</p>
<pre class="brush: bash; title: ; notranslate">
umount /data45
rmfs /data45 
</pre>
<p>I had a volume group that was consisting of only one filesystem, so when I removed the file system, volume group was automatically removed. There is no need to use <strong>rmlv</strong>. Then I checked the volume group.</p>
<pre class="brush: bash; title: ; notranslate">lsvg -M datavg04 </pre>
<p>I saw that there was a log logical volume, so I have to remove it manually.</p>
<pre class="brush: bash; title: ; notranslate">rmlv loglv04 </pre>
<p>Now, you have to list physical volumes (actual EMC drives) that are part of <strong>datavg04</strong>:</p>
<pre class="brush: bash; title: ; notranslate">lspv -L | grep datavg04 </pre>
<p>Write down these hpowerdisk devices and for each of them do</p>
<pre class="brush: bash; title: ; notranslate">powermt display dev=hdiskpowerXYZ </pre>
<p>You will see that hpowerdiskXYZ is a representation of (in my case) two hard disks named hdiskAA and hdiskBB. AA and BB are random numbers. This means that hdiskpowerXYZ is a virtual single hard drive for AIX, but it is an actual mirrored hard drive for EMC consisting of two physical drives. Now that we have this information, we can remove the drives from the volume group first.</p>
<pre class="brush: bash; title: ; notranslate">reducevg datavg04 hdiskpowerXYZ
reducevg datavg04 hdiskpowerZYX </pre>
<p>Once you delete the last hdiskpower device from the VG (volume group), the VG will be removed automatically. But we are not done yet. We have to remove the drives, so the OS won’t look for them.</p>
<pre class="brush: bash; title: ; notranslate">powermt remove dev=hdiskpowerXYZ
rmdev -Rdl hdiskpowerXYZ
rmdev -Rdl hdiskAA
rmdev - Rdl hdiskBB </pre>
<p>Once you remove every instance of hdiskpower and hdisk devices, you can:</p>
<pre class="brush: bash; title: ; notranslate"> powermt save</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2012/01/remove-emc-lunsvgsdisks-from-aix-powerpath/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>General: postfix relay for another domain</title>
		<link>https://blog.andreev.it/2012/01/postfix-relay-for-other-domain/</link>
					<comments>https://blog.andreev.it/2012/01/postfix-relay-for-other-domain/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Wed, 18 Jan 2012 19:30:36 +0000</pubDate>
				<category><![CDATA[AIX]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[relay]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=235</guid>

					<description><![CDATA[I have two registered domains both pointing to my FreeBSD external IP. The first&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>I have two registered domains both pointing to my FreeBSD external IP. The first one is chombe.org and I receive these e-mails on my FreeBSD using postfix. The second domain is klimentandreev.com and I use Exchange 2003 to receive e-mails for this domain. Since Exchange is on the internal network, I have to configure postfix to relay all e-mails for klimentandreev.com to the Exchange box.</p>
<p>First, I made sure that I can ping klimentandreev.com from FreeBSD box and that it will resolve to my internal IP. Next, I edited <strong>main.cf</strong> and changed <strong>relay_domains</strong> to be like this.</p>
<pre class="brush: bash; title: ; notranslate">
relay_domains = $mydestionation, /usr/local/etc/postfix/relay-domains 
</pre>
<p>Then, I created that file and added the following lines.</p>
<pre class="brush: bash; title: ; notranslate">
# Relay domains
klimentandreev.com
other-domain-that-i-will-probably-buy.com
</pre>
<p>After that, I reloaded postfix with <strong>/usr/local/etc/rc.d/postfix reload</strong> and I verified that postfix is relaying OK. I didn’t have to configure anything on the Exchange box.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2012/01/postfix-relay-for-other-domain/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AIX: Legato NetWorker FC tape problem</title>
		<link>https://blog.andreev.it/2011/12/aix-legato-networker-fc-tape-problem/</link>
					<comments>https://blog.andreev.it/2011/12/aix-legato-networker-fc-tape-problem/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Mon, 05 Dec 2011 20:04:46 +0000</pubDate>
				<category><![CDATA[AIX]]></category>
		<category><![CDATA[Legato]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=159</guid>

					<description><![CDATA[While IT was performing fiber switch upgrade, they moved the cable that goes from&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>While IT was performing fiber switch upgrade, they moved the cable that goes from the AIX box to the TAN switch. Windows servers needed to be rebooted in order to rescan the bus and re-recognize the tape jukebox, but AIX refused to accept the new configuration. First I tried <strong>cfgmgr</strong> but nothing happened. Rebooting the server also didn’t help. The only solution was to unconfigure the <strong>fcs </strong>adapter. Let’s see how the tape config looks like:</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
lsdev -Cc tape
rmt0 Available 2U-08-02 Other FC SCSI Tape Drive
rmt1 Available 2U-08-02 Other FC SCSI Tape Drive
rmt2 Available 2U-08-02 Other FC SCSI Tape Drive 
</pre>
<p>Once I got the location, I can search for the adapter:</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
lsdev -C | grep 2U-08
fcnet2         Defined   2U-08-01     Fibre Channel Network Protocol Device
fcs2           Available 2U-08        FC Adapter
fscsi2         Available 2U-08-02     FC SCSI I/O Controller Protocol Device
rmt0           Available 2U-08-02     Other FC SCSI Tape Drive
rmt1           Available 2U-08-02     Other FC SCSI Tape Drive
rmt2           Available 2U-08-02     Other FC SCSI Tape Drive 
</pre>
<p>Luckily for me, I don’t have any hard disks attached to fcs2 so there is no need to vary off VGs. I tried to remove the fcs2 and all &#8220;children&#8221; devices but I was getting device busy error.</p>
<pre class="brush: bash; title: ; notranslate">
rmdev - Rdl fcs2 
</pre>
<p>The solution is to unplug the fiber cable from port 2 and reboot the server. Once the server was back, I was able to remove the devices with <strong>rmdev</strong>. I plugged the cable back, waited 1-2 minutes for AIX to sync and then run <strong>cfgmgr </strong>again. After 2-3 minutes I got my tapes back and Legato NetWorker was able to recognize them with <strong>inquire</strong> command.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2011/12/aix-legato-networker-fc-tape-problem/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
