Execute a command with a timeout

2010-12-29 1 min read Bash Learning
Official Ubuntu circle with wordmark. Replace ...
  <dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">
    Image via <a href="http://commons.wikipedia.org/wiki/File:Ubuntu_logo.svg">Wikipedia</a>
  </dd>
</dl>

Execute a command with a timeout

  <td>
    <div class="text codecolorer">
      &nbsp;timelimit -t100 somecommand
    </div>
  </td>
</tr>
1

I found this in Ubuntu repos, and consider it better than timeout.

* View this command to comment, vote or add to favourites * View all commands by CodSpirit

Continue reading

\[Solution\] Solaris issue with wget not resolving Domain name (DNS name lookup failure)

2010-08-09 2 min read Solaris

Today I was working with <a class="zem_slink" title="Solaris (operating system)" rel="homepage" href="http://oracle.com/solaris">Solaris and after I had set up the <a class="zem_slink" title="NIS+" rel="wikipedia" href="http://en.wikipedia.org/wiki/NIS%2B">NIS+, <a class="zem_slink" title="Name server" rel="wikipedia" href="http://en.wikipedia.org/wiki/Name_server">DNS server, IP Address and completing the basic setting. I was using the pkg-get util from the freesunware.com

The utility was using wget and it was failing constantly. From the looks of it, it was very clear that the wget utility was unable to find the <a class="zem_slink" title="IP address" rel="wikipedia" href="http://en.wikipedia.org/wiki/IP_address">IP address from the name. <a class="zem_slink" title="Name resolution" rel="wikipedia" href="http://en.wikipedia.org/wiki/Name_resolution">Name resolution was not happening, while dig and <a class="zem_slink" title="Nslookup" rel="wikipedia" href="http://en.wikipedia.org/wiki/Nslookup">nslookup was able to do the DNS lookup.

Continue reading

vim – get the list of all the scripts available.

2010-05-27 1 min read Learning Linux Vim Tips

To get a list of all the scripts in the vim.sf.net project, you can run the following command. This will list all the scripts with the script id.

wget -O – &#8217;http://www.vim.org/scripts/script_search_results.php?&show_me=4000&result_ptr=0&#8217; -o /dev/null | <a class="zem_slink freebase/en/grep" title="Grep" rel="wikipedia" href="http://en.wikipedia.org/wiki/Grep">grep width| grep script_id= |<a class="zem_slink freebase/en/sed" title="Sed" rel="wikipedia" href="http://en.wikipedia.org/wiki/Sed">sed &#8217;s/.*script_id=//&#8217;|tr -d &#8221;&#8221;&#8221;|tr &#8221;>&#8221; &#8221; &#8221;|sed &#8217;s/< .*//&#8217; | tr -d &#8217;\001&#8217;-&#8217;\011&#8217;&#8217;\013&#8217;&#8217;\014&#8217;&#8217;\016&#8217;-&#8217;\037&#8217;&#8217;\200&#8217;-&#8217;\377&#8217; |sort -n<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://www.slumpedoverkeyboarddead.com/2009/09/17/use-curl-to-monitor-your-vonage-phone-bill/">Use curl to Monitor Your Vonage Phone Bill (slumpedoverkeyboarddead.com) <li class="zemanta-article-ul-li"><a href="http://securewebs.com/yum-updates/">Yum Updates (securewebs.com) <li class="zemanta-article-ul-li"><a href="http://www.gubatron.com/blog/2009/10/10/ubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line/">Ubuntu/Debian Quick Reference: How To Change Your Server&#8217;s UTC Timezone on the command line (gubatron.com) <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2009/11/22/short-information-about-loaded-kernel-modules/">Short Information about loaded kernel modules (amit-agarwal.co.in) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/b22b2e85-8107-4f9b-9130-85a8e8ae370b/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b52.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">

Continue reading

Mirror or download a website with a tool much better than wget

2010-05-19 1 min read Bash Fedora Linux

If you want to mirror a <a class="zem_slink freebase/en/website" title="Website" rel="wikipedia" href="http://en.wikipedia.org/wiki/Website">website, the simplest tool I know if is <a class="zem_slink freebase/en/wget" title="Wget" rel="homepage" href="http://www.gnu.org/software/wget/">wget. Once you have used wget, you know the troubles associated with it. You also get added couple of files as search html files, which are useless and wastage of bandwidth for you as well as the <a class="zem_slink freebase/en/web_server" title="Web server" rel="wikipedia" href="http://en.wikipedia.org/wiki/Web_server">webserver.

lftp -e &#8221;mirror -c&#8221; 

Continue reading

Download with browse with bash and wget

2010-05-09 1 min read Bash Fedora

Been pretty busy for last couple of days. Will be busy for another few days, but here&#8217;s something to munch in the meantime (Script may need changes depending on the type of file you want to download or the site you are browsing, but the chnages should be minimal):

file=&#8221;/tmp/temp.dir&#8221;
url=&#8221;URL Here&#8221;
IFS=&#8217;
&#8217;
cont=&#8221;y&#8221;
while [ $cont != &#8221;n&#8221; ]
do
name=&#8221;&#8221;
wget &#8221;$url&#8221; -O $file -o /dev/null
for i in $(grep href $file |grep -v Parent)
do
name=${i##href=&#8221;}
name=${name%%&#8221;>
}
echo $name
if [[ $name == *gz ]]
then
cont=&#8221;n&#8221;
fi
done
if [ ! $name ]
then
echo &#8221;No files here.. Exiting&#8221;
exit -1
fi
echo
if [ $cont == &#8221;n&#8221; ]
then
echo &#8221;Enter the filename for download :&#8221;
read file
fi
echo &#8221;Select one of the options:&#8221;
read product
url=&#8221;$url/$product&#8221;
echo &#8221;About to get $url&#8221;
done
wget &#8221;$url&#8221; -O $file -o /dev/null

Continue reading