<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.2" -->
<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/"
	>

<channel>
	<title>Linux Hints, Tips, and Tricks</title>
	<link>http://puschitz.com/pblog</link>
	<description>Linux Hints, Tips, and Tricks</description>
	<pubDate>Sun, 12 Apr 2009 18:26:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>
	<language>en</language>
			<item>
		<title>Running 32-bit Cisco AnyConnect VPN Client 2.2 on 64-bit Ubuntu 8.10</title>
		<link>http://puschitz.com/pblog/?p=39</link>
		<comments>http://puschitz.com/pblog/?p=39#comments</comments>
		<pubDate>Sat, 11 Apr 2009 01:42:57 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=39</guid>
		<description><![CDATA[Running 32-bit Cisco AnyConnect VPN Client 2.2 on 64-bit Ubuntu 8.10 desktop will result in some errors if certain 32-bit shared libraries are missing:
# ./vpnsetup.sh
Installing Cisco AnyConnect VPN Client &#8230;
Extracting installation files to /tmp/vpn.k13598&#8230;
ciscovpn/
ciscovpn/vpn_install.sh
ciscovpn/vpnagentd
ciscovpn/vpnagentd_init
ciscovpn/vpn_uninstall.sh
ciscovpn/libssl.so.0.9.8
ciscovpn/libcrypto.so.0.9.8
ciscovpn/vpnui
ciscovpn/anyconnect.desktop
ciscovpn/vpn
ciscovpn/pixmaps/
ciscovpn/pixmaps/company-logo.png
ciscovpn/pixmaps/cvc-about.png
ciscovpn/pixmaps/cvc-connect.png
ciscovpn/pixmaps/cvc-disconnect.png
ciscovpn/pixmaps/cvc-info.png
ciscovpn/pixmaps/systray_connected.png
ciscovpn/pixmaps/systray_disconnecting.png
ciscovpn/pixmaps/systray_notconnected.png
ciscovpn/pixmaps/systray_reconnecting.png
ciscovpn/pixmaps/vpnui48.png
ciscovpn/VPNManifest.dat
ciscovpn/vpndownloader.sh
ciscovpn/update.txt
ciscovpn/license.txt
Starting the VPN agent&#8230;
/etc/init.d/vpnagentd_init: 68: /opt/cisco/vpn/bin/vpnagentd: not found
#
$ /opt/cisco/vpn/bin/vpn
Cisco AnyConnect VPN Client (version 2.2.0136).

Copyright (c) 2004 - 2008 Cisco Systems, Inc.
All Rights [...]]]></description>
			<content:encoded><![CDATA[<p>Running 32-bit Cisco AnyConnect VPN Client 2.2 on 64-bit Ubuntu 8.10 desktop will result in some errors if certain 32-bit shared libraries are missing:</p>
<pre># <font color="#0000ff">./vpnsetup.sh</font>
Installing Cisco AnyConnect VPN Client &#8230;
Extracting installation files to /tmp/vpn.k13598&#8230;
ciscovpn/
ciscovpn/vpn_install.sh
ciscovpn/vpnagentd
ciscovpn/vpnagentd_init
ciscovpn/vpn_uninstall.sh
ciscovpn/libssl.so.0.9.8
ciscovpn/libcrypto.so.0.9.8
ciscovpn/vpnui
ciscovpn/anyconnect.desktop
ciscovpn/vpn
ciscovpn/pixmaps/
ciscovpn/pixmaps/company-logo.png
ciscovpn/pixmaps/cvc-about.png
ciscovpn/pixmaps/cvc-connect.png
ciscovpn/pixmaps/cvc-disconnect.png
ciscovpn/pixmaps/cvc-info.png
ciscovpn/pixmaps/systray_connected.png
ciscovpn/pixmaps/systray_disconnecting.png
ciscovpn/pixmaps/systray_notconnected.png
ciscovpn/pixmaps/systray_reconnecting.png
ciscovpn/pixmaps/vpnui48.png
ciscovpn/VPNManifest.dat
ciscovpn/vpndownloader.sh
ciscovpn/update.txt
ciscovpn/license.txt
Starting the VPN agent&#8230;
<font color="#ff0000">/etc/init.d/vpnagentd_init: 68: /opt/cisco/vpn/bin/vpnagentd: not found</font>
#</pre>
<pre>$ <font color="#0000ff">/opt/cisco/vpn/bin/vpn</font>
Cisco AnyConnect VPN Client (version 2.2.0136).

Copyright (c) 2004 - 2008 Cisco Systems, Inc.
All Rights Reserved.

  &gt;&gt; warning: No profile is available.  Please enter host to &#8220;Connect to&#8221;.
  &gt;&gt; state: Disconnected
  &gt;&gt; notice: VPN Service is available.
  &gt;&gt; registered with local VPN subsystem.
  &gt;&gt; state: Disconnected
VPN&gt; connect xx.xx.xx.xx
  &gt;&gt; contacting host (xx.xx.xx.xx) for login information&#8230;
  &gt;&gt; notice: Contacting xx.xx.xx.xx.
  <font color="#ff0000">&gt;&gt; warning: Unable to process response from xx.xx.xx.xx.
  &gt;&gt; error: Connection attempt has failed due to server certificate problem.
  &gt;&gt; state: Disconnected</font>
VPN&gt; exit
goodbye&#8230;
$</pre>
<p>Here are the steps I executed on my Ubuntu desktop to resolve this issue:</p>
<p>Download and install <tt>getlibs</tt>:</p>
<pre># <font color="#0000ff">wget http://www.boundlesssupremacy.com/Cappy/getlibs/getlibs-all.deb</font>
# <font color="#0000ff">dpkg -i getlibs-all.deb</font></pre>
<p>Install 32-bit shared libraries:</p>
<pre># <font color="#0000ff">getlibs /opt/cisco/vpn/bin/vpn</font>
# <font color="#0000ff">getlibs libsqlite3.so.0</font></pre>
<p>Create some symbolic links:</p>
<pre># <font color="#0000ff">mkdir /usr/local/firefox</font>
# <font color="#0000ff">cd /usr/local/firefox</font>
# <font color="#0000ff">ln -s /usr/lib32/libnss3.so</font>
# <font color="#0000ff">ln -s /usr/lib32/libplc4.so</font>
# <font color="#0000ff">ln -s /usr/lib32/libnspr4.so</font>
# <font color="#0000ff">ln -s /usr/lib32/libsmime3.so</font></pre>
<p>Now re-run <tt>vpnsetup.sh</tt> and launch <tt>vpn</tt>:</p>
<pre># <font color="#0000ff">./vpnsetup.sh</font>
$ <font color="#0000ff">/opt/cisco/vpn/bin/vpn</font></pre>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=39</wfw:commentRss>
		</item>
		<item>
		<title>Memory Fragmentation</title>
		<link>http://puschitz.com/pblog/?p=28</link>
		<comments>http://puschitz.com/pblog/?p=28#comments</comments>
		<pubDate>Wed, 26 Sep 2007 04:06:13 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=28</guid>
		<description><![CDATA[When a Linux system has been running for a while memory fragmentation can increase which depends heavily on the nature of the applications that are running on it. The more processes allocate and free memory, the quicker memory becomes fragmented. And the kernel may not always be able to defragment enough memory for a requested [...]]]></description>
			<content:encoded><![CDATA[<p>When a Linux system has been running for a while memory fragmentation can increase which depends heavily on the nature of the applications that are running on it. The more processes allocate and free memory, the quicker memory becomes fragmented. And the kernel may not always be able to defragment enough memory for a requested size on time. If that happens, applications may not be able to allocate larger contiguous chunks of memory even though there is enough free memory available. Starting with the 2.6 kernel, i.e. RHEL4 and SLES9, memory management has improved tremendously and memory fragmentation has become less of an issue.</p>
<p>To see memory fragmentation you can use the magic SysRq key. Simply execute the following command:</p>
<pre># <font color="#0000ff">echo m &gt; /proc/sysrq-trigger</font></pre>
<p>This command will dump current memory information to /var/log/messages. Here is an example of a RHEL3 32-bit system:</p>
<pre>Jul 23 20:19:30 localhost kernel: 0*4kB 0*8kB 0*16kB 1*32kB 0*64kB 1*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 1952kB)
Jul 23 20:19:30 localhost kernel: 1395*4kB 355*8kB 209*16kB 15*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 12244kB)
Jul 23 20:19:31 localhost kernel: 1479*4kB 673*8kB 205*16kB 73*32kB 21*64kB 847*128kB 473*256kB 92*512kB 164*1024kB 64*2048kB 28*4096kB = 708564kB)</pre>
<p>The first line shows DMA memory fragmentation. The second line shows Low Memory fragmentation and the third line shows High Memory fragmentation. The output shows memory fragmentation in the Low Memory area. But there are many large memory chunks available in the High Memory area, e.g. 28 4MB.</p>
<p>If memory information was not dumped to /var/log/messages, then SysRq was not enabled. You can enable SysRq by setting sysrq to 1:</p>
<pre># <font color="#0000ff">echo 1 &gt; /proc/sys/kernel/sysrq</font></pre>
<p>Starting with the 2.6 kernel, i.e. RHEL4 and SLES9, you don&#8217;t need SysRq to dump memory information. You can simply check /proc/buddyinfo for memory fragmentation.</p>
<p>Here is the output of a 64-bit server running the 2.6 kernel:</p>
<pre><font color="#0000ff"># cat /proc/buddyinfo</font>
Node 0, zone DMA 5 4 3 4 3 2 1 0 1 1 2
Node 0, zone Normal 1046 527 128 36 17 5 26 40 13 16 94
# <font color="#0000ff">echo m &gt; /proc/sysrq-trigger</font>
# <font color="#0000ff">grep Normal /var/log/messages | tail -1</font>
Jul 23 21:42:26 localhost kernel: Normal: 1046*4kB 529*8kB 129*16kB 36*32kB 17*64kB 5*128kB 26*256kB 40*512kB 13*1024kB 16*2048kB 94*4096kB = 471600kB
#</pre>
<p>In this example I used SysRq again to show what each number in /proc/buddyinfo is referring to.</p>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=28</wfw:commentRss>
		</item>
		<item>
		<title>Calculations in Scripts</title>
		<link>http://puschitz.com/pblog/?p=33</link>
		<comments>http://puschitz.com/pblog/?p=33#comments</comments>
		<pubDate>Tue, 11 Sep 2007 00:52:25 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=33</guid>
		<description><![CDATA[To do simple calculations in bash, the ((…)) command can be used:
$ echo $(( 10 + 10 ))
20
To do floating point or more complex math, try the bc command:
$ echo "scale=5; 5/3" &#124; bc
1.66666
To convert hex values to decimal, the ((…)) or bc command can be used:
$ echo $((0xff))
255
$ echo 'obase=10; ibase=16; FF' &#124; bc
255
Note [...]]]></description>
			<content:encoded><![CDATA[<p>To do simple calculations in bash, the <tt>((…))</tt> command can be used:</p>
<pre>$ <font color="#0000ff">echo $(( 10 + 10 ))</font>
20</pre>
<p>To do floating point or more complex math, try the <tt>bc</tt> command:</p>
<pre>$ <font color="#0000ff">echo <code>"</code>scale=5; 5/3<code>"</code> | bc</font>
1.66666</pre>
<p>To convert hex values to decimal, the <tt>((…))</tt> or <tt>bc</tt> command can be used:</p>
<pre>$ <font color="#0000ff">echo $((0xff))</font>
255
$ <font color="#0000ff"><code>echo 'obase=10; ibase=16; FF' | bc</code></font>
255</pre>
<p>Note that the hex value must be in uppercase letters if you use the <tt>bc</tt> command.</p>
<p>To convert decimal to hex:</p>
<pre>$ <font color="#0000ff"><code>echo 'obase=16; ibase=10; 255' | bc</code></font>
FF</pre>
<p>To convert hex to binary:</p>
<pre>$ <font color="#0000ff"><code>echo 'obase=2; ibase=16; FF' | bc</code></font>
11111111</pre>
<p>To do unit conversions, you can use the <tt>units</tt> command:</p>
<pre>$ <font color="#0000ff"><code>units -t '1mile' 'km'</code></font>
1.609344</pre>
<p>Or to do definition lookups:</p>
<pre>$ <font color="#0000ff"><code>units -t '1 googol'</code></font>
        Definition: 1e+100</pre>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=33</wfw:commentRss>
		</item>
		<item>
		<title>Kernel Modules</title>
		<link>http://puschitz.com/pblog/?p=32</link>
		<comments>http://puschitz.com/pblog/?p=32#comments</comments>
		<pubDate>Fri, 07 Sep 2007 05:13:50 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=32</guid>
		<description><![CDATA[To find out what a particular driver/module does, the modinfo command can be used in many cases:
# modinfo -d e1000
Intel(R) PRO/1000 Network Driver
#

# modinfo -d hangcheck-timer
Hangcheck-timer detects when the system has gone out to lunch past a certain margin.
#
To get a list of parameters supported by a kernel driver/module, the modinfo -p command will usually [...]]]></description>
			<content:encoded><![CDATA[<p>To find out what a particular driver/module does, the <tt>modinfo</tt> command can be used in many cases:</p>
<pre># <font color="#0000ff">modinfo -d e1000</font>
Intel(R) PRO/1000 Network Driver
#

# <font color="#0000ff">modinfo -d hangcheck-timer</font>
Hangcheck-timer detects when the system has gone out to lunch past a certain margin.
#</pre>
<p>To get a list of parameters supported by a kernel driver/module, the <tt>modinfo -p</tt> command will usually provide the information:</p>
<pre># <font color="#0000ff">modinfo -p e1000</font>
debug:Debug level (0=none,&#8230;,16=all)
InterruptThrottleRate:Interrupt Throttling Rate
RxAbsIntDelay:Receive Absolute Interrupt Delay
RxIntDelay:Receive Interrupt Delay
TxAbsIntDelay:Transmit Absolute Interrupt Delay
TxIntDelay:Transmit Interrupt Delay
XsumRX:Disable or enable Receive Checksum offload
FlowControl:Flow Control setting
AutoNeg:Advertised auto-negotiation setting
Duplex:Duplex setting
Speed:Speed setting
RxDescriptors:Number of receive descriptors
TxDescriptors:Number of transmit descriptors
#
# <font color="#0000ff">modinfo -p hangcheck-timer</font>
hangcheck_dump_tasks:If nonzero, the machine will dump the system task state when the timer margin is exceeded.
hangcheck_reboot:If nonzero, the machine will reboot when the timer margin is exceeded.
hangcheck_margin:If the hangcheck timer has been delayed more than hangcheck_margin seconds, the driver will fire.
hangcheck_tick:Timer delay.
#</pre>
<p>To set parameters during module loads, you can add entries to <tt><font color="#0000ff">/etc/modprobe.conf</font></tt> on RHEL or <tt><font color="#0000ff">/etc/modprobe.conf.local</font></tt> on SLES. For example:</p>
<pre><font color="#0000ff">options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180</font></pre>
<p>To load the module and see the new settings, run:</p>
<pre># <font color="#0000ff">modprobe -v hangcheck-timer</font>
insmod /lib/modules/2.6.9-22.EL/kernel/drivers/char/hangcheck-timer.ko hangcheck_tick=20 hangcheck_margin=280
#
# <font color="#0000ff">dmesg | tail -1</font>
Hangcheck: starting hangcheck timer 0.5.0 (tick is 30 seconds, margin is 180 seconds).
#</pre>
<p>The newly loaded module will be at the top of the <tt>lsmod</tt> list:</p>
<pre># <font color="#0000ff">lsmod | head -2</font>
Module Size Used by
hangcheck_timer 3289 0
#</pre>
<p>To unload the module, run:</p>
<pre># <font color="#0000ff">rmmod hangcheck-timer</font></pre>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=32</wfw:commentRss>
		</item>
		<item>
		<title>Renaming Files</title>
		<link>http://puschitz.com/pblog/?p=31</link>
		<comments>http://puschitz.com/pblog/?p=31#comments</comments>
		<pubDate>Wed, 05 Sep 2007 00:11:01 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=31</guid>
		<description><![CDATA[To rename all files in a directory and add a new extension the xargs command can be used:
ls &#124; xargs -t -i mv {} {}.old
xargs reads each item from the ls ouput and executes the mv command. The &#8216;-i&#8217; option tells xargs to replace &#8216;{}&#8217;  with the name of each item. The &#8216;-t&#8217; option [...]]]></description>
			<content:encoded><![CDATA[<p>To rename all files in a directory and add a new extension the <tt>xargs</tt> command can be used:</p>
<pre><font color="#0000ff">ls | xargs -t -i mv {} {}.old</font></pre>
<p><tt>xargs</tt> reads each item from the <tt>ls</tt> ouput and executes the <tt>mv</tt> command. The &#8216;-i&#8217; option tells <tt>xargs</tt> to replace &#8216;{}&#8217;  with the name of each item. The &#8216;-t&#8217; option instructs <tt>xargs</tt> to print the command before executing it.</p>
<p>To rename a subset of files, specify the file names with the <tt>ls</tt> command:</p>
<pre><font color="#0000ff">ls *.log | xargs -t -i mv {} {}.old</font></pre>
<p>Or to add a current timestamp extension you may want to use the <tt>date</tt> command similar to this one:</p>
<pre><font color="#0000ff">ls *.log | xargs -t -i mv {} {}.`date +%F-%H:%M:%S`</font></pre>
<p>The extension will look like &#8220;.2006-08-10-19:37:16&#8243;.</p>
<p>If you want to rename the extension of files, try the <tt>rename</tt> command:</p>
<pre><font color="#0000ff">rename .log .log_archive.`date +%F-%H:%M:%S` *</font></pre>
<p>This command replaces the first occurrence of &#8216;.log&#8217; in the name by .log_archive.`date +%F-%H:%M:%S`.</p>
<p>The following command replaces .htm extensions with .html for all files that start with &#8220;project*&#8221;:</p>
<pre><font color="#0000ff">rename .htm .html project*</font></pre>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=31</wfw:commentRss>
		</item>
		<item>
		<title>Simple Network Performance Test</title>
		<link>http://puschitz.com/pblog/?p=30</link>
		<comments>http://puschitz.com/pblog/?p=30#comments</comments>
		<pubDate>Mon, 03 Sep 2007 01:15:21 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=30</guid>
		<description><![CDATA[To do a simple and quick network performance test the ftp command can be used.
FTP on Linux and other Unix systems allows you to pass shell commands to the ftp client by using the pipe symbol &#8216;&#124;&#8217; as  the first character of the file name. With this feature you can send a very large [...]]]></description>
			<content:encoded><![CDATA[<p>To do a simple and quick network performance test the <tt>ftp</tt> command can be used.</p>
<p>FTP on Linux and other Unix systems allows you to pass shell commands to the <tt>ftp</tt> client by using the pipe symbol &#8216;|&#8217; as  the first character of the file name. With this feature you can send a very large file to a remote host using <tt>/dev/zero</tt> as input and <tt>/dev/null</tt> as output.</p>
<p>Example:</p>
<pre><font color="#0000ff"><code>ftp&gt; put "|dd if=/dev/zero bs=1M count=100" /dev/null</code></font></pre>
<p>This command transfers a large file without involving the disk and without having to cache the file in memory. If you use a large file on a disk it might become a bottleneck. In this example, <tt>&#8220;|dd if=/dev/zero bs=1M count=100&#8243;</tt> becomes the input file. Since a <tt>dd</tt> command without the <tt>&#8220;of=&#8221;</tt> paramater prints the content of the file to  standard output (stdout), the ftp client can read the output and pass it on to the remote file which is <tt>/dev/null</tt> on the remote host.</p>
<h3><font color="#0000ff"><u><a title="RetrievingHardwareInformation" name="RetrievingHardwareInformation"></a></u></font></h3>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=30</wfw:commentRss>
		</item>
		<item>
		<title>Retrieving Hardware Information</title>
		<link>http://puschitz.com/pblog/?p=29</link>
		<comments>http://puschitz.com/pblog/?p=29#comments</comments>
		<pubDate>Sun, 02 Sep 2007 02:58:38 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=29</guid>
		<description><![CDATA[To retrieve information on system&#8217;s hardware like vendor, manufacturer, product, S/N, etc. the following command can be used:
dmidecode
The dmidecode command reads the information from the system BIOS, see also  http://www.nongnu.org/dmidecode/.
There are a few other commands you might want to check out which list installed hardware components:
dmesg
lsdev
lshal
lspci
lsusb
lsscsi

Beginning with the 2.6 kernel you can get lots [...]]]></description>
			<content:encoded><![CDATA[<p>To retrieve information on system&#8217;s hardware like vendor, manufacturer, product, S/N, etc. the following command can be used:</p>
<pre><font color="#0000ff">dmidecode</font></pre>
<p>The <tt>dmidecode</tt> command reads the information from the system BIOS, see also  <a href="http://www.nongnu.org/dmidecode/">http://www.nongnu.org/dmidecode/</a>.</p>
<p>There are a few other commands you might want to check out which list installed hardware components:</p>
<pre><font color="#0000ff">dmesg
lsdev
lshal
lspci
lsusb
lsscsi
</font></pre>
<p>Beginning with the 2.6 kernel you can get lots of information from /sys. For example, to get information on an Emulex HBA:</p>
<pre># <font color="#0000ff">ls /sys/class/scsi_host/host1/</font>
board_mode     lpfc_cr_delay            lpfc_poll             option_rom_version
board_online   lpfc_drvr_version        lpfc_poll_tmo         portnum
cmd_per_lun    lpfc_fcp_class           lpfc_scan_down        proc_name
ctlreg         lpfc_fdmi_on             lpfc_topology         programtype
device         lpfc_hba_queue_depth     lpfc_use_adisc        scan
fwrev          lpfc_link_speed          management_version    serialnum
hdw            lpfc_log_verbose         mbox                  sg_tablesize
host_busy      lpfc_lun_queue_depth     modeldesc             state
info           lpfc_max_luns            modelname             uevent
lpfc_ack0      lpfc_multi_ring_support  nport_evt_cnt         unchecked_isa_dma
lpfc_cr_count  lpfc_nodev_tmo           num_discovered_ports  unique_id
#</pre>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=29</wfw:commentRss>
		</item>
		<item>
		<title>Debugging Scripts</title>
		<link>http://puschitz.com/pblog/?p=27</link>
		<comments>http://puschitz.com/pblog/?p=27#comments</comments>
		<pubDate>Tue, 14 Aug 2007 02:48:25 +0000</pubDate>
		<dc:creator>werner</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://puschitz.com/pblog/?p=27</guid>
		<description><![CDATA[Sometimes it can be difficult to debug scripts. For example, a script only fails if it&#8217;s being executed by an application and you have no way of telling the application how the script should be executed to redirect the output. Or you simply don&#8217;t want to redirect the output of the script each time you [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it can be difficult to debug scripts. For example, a script only fails if it&#8217;s being executed by an application and you have no way of telling the application how the script should be executed to redirect the output. Or you simply don&#8217;t want to redirect the output of the script each time you execute it.</p>
<p>Adding the following lines at the beginning of the script can be very useful:</p>
<pre><font color="#0000ff"><code>export PS4='$0.$LINENO+ '
exec &gt; /tmp/script.log
exec 2&gt;&amp;1
set -x</code></font></pre>
<p>Example:</p>
<pre> cat test
#!/bin/bash
export PS4='$0.$LINENO+ '
exec &gt; /tmp/script.log
exec 2&gt;&amp;1
set -x
ls -ld /etc
ls -ld /boot
echo "This is a test"</pre>
<pre>$ ./test
$ cat /tmp/script.log
./test.6+ ls -ld /etc
drwxr-xr-x 83 root root 7512 2006-07-22 16:49 /etc
./test.7+ ls -ld /boot
drwxr-xr-x 5 root root 1960 2006-07-22 15:30 /boot
./test.8+ echo 'This is a test'
This is a test
$</pre>
<p>These lines will turn on debugging and all information will be redirected to the log file. So you won’t have to redirect the output each time you run the script, e.g. “./script &gt; /tmp/script.log 2&gt;&amp;1″. In some cases you can’t do that if the script is invoked by an application.</p>
<p>The PS4 builtin shell variable describes the prompt seen in debug mode. The $0 variable stands for the name of the script file itself. $LINENO shows the current line number within the script. The exec command redirects I/O streams. The first exec command redirects stdout stream 1 to /tmp/script.log. 2&gt;&amp;1 redirects stderr stream 2 to stdout stream 1. And “set -x” enables debugging.</p>
]]></content:encoded>
			<wfw:commentRss>http://puschitz.com/pblog/?feed=rss2&amp;p=27</wfw:commentRss>
		</item>
	</channel>
</rss>

