Determine what process is listening on a port on Solaris, without lsof

2010-06-08 0 min read Linux Solaris
\"Desktop
Image by Metsuke iLife via Flickr

$ for x in `ptree | <a class="zem_slink freebase/en/awk" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk '{print $1}&#8217;`; do pfiles $x | <a class="zem_slink freebase/en/grep" title="Grep" rel="wikipedia" href="http://en.wikipedia.org/wiki/Grep">grep ${PORT} > /dev/null 2>&1; if [ x&#8221;$?&#8221; == &#8221;x0&#8221; ]; then ps -ef | grep $x | grep -v grep; fi; done 2> /dev/null

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

more powerful grep – ack

2010-05-26 2 min read Bash Fedora

For last couple of days, I have been using ack instead of grep. Here is description of ack:

Ack is designed as a replacement for grep.

There are couple of reasons I am using ack. First and foremost being it does not require a filename. So, for seaching amit in all files recursively under the current directory I can simply use

ack amit

More reasons to use ack:

It supports pager option and there can be a rc file that can be used to define the default options that needs to be used with ack. Here is the contents of my $HOME/.ackrc file.

Continue reading

Script to download all the related videos from youtube with youtube-dl

2010-05-17 2 min read Fedora Linux Uncategorized

Lets cut the long discussion <a class="zem_slink freebase/en/short_subject" title="Short film" rel="wikipedia" href="http://en.wikipedia.org/wiki/Short_film">short and directly give you the script. The script is combination of all the posts that I did in the past about youtube <a class="zem_slink freebase/en/uploading_and_downloading" title="Uploading and downloading" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uploading_and_downloading">downloads. You need to copy all the <a class="zem_slink freebase/en/uniform_resource_locator" title="Uniform Resource Locator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL&#8217;s in a file called &#8221;~/youtube.urls&#8221; which you want to be downloaded. Or if you need to donwload the related videos, then save the html of the page and give it as the first argument for the script. So, here&#8217;s the scrit:

Continue reading

Downloading all related videos from youtube with youtube-dl

2010-05-16 2 min read Fedora Learning Linux Uncategorized

How many time did you want to see all the videos (related) to the one you were watching on youtube but decided otherwise as the downloaded was not fast enough. Or has it happened to you that you wanted to <a class="zem_slink freebase/en/uploading_and_downloading" title="Uploading and downloading" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uploading_and_downloading">download all the related videos, in either case you can use the youtube-dl utility I blogged about some times back. First you need to get all the <a class="zem_slink freebase/en/uniform_resource_locator" title="Uniform Resource Locator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL&#8217;s in a <a class="zem_slink freebase/en/text_file" title="Text file" rel="wikipedia" href="http://en.wikipedia.org/wiki/Text_file">text file, and the simplest way to do this is :

Continue reading

Script to get the number of events from the logs.

2010-04-11 2 min read Learning Linux Perl

<a id="aptureLink_4P0PJ73NaG" style="margin: 0pt auto; padding: 0px 6px; text-align: center; display: block;" href="http://en.wikipedia.org/wiki/Log%20analysis"><img style="border: 0px none;" title="Log analysis" src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/ph/360x320_WikipediaArticle" alt="" width="360px" height="320px" />

I was trying to do some <a class="zem_slink freebase/en/log_analysis" title="Log analysis" rel="wikipedia" href="http://en.wikipedia.org/wiki/Log_analysis">log analysis and finding the events in the logs. For this the logs had the Events logged as &#8221;|+Event name|&#8221; or with sending and receiving. So I wrote this little script to take care of my requirements.

Continue reading

Extract all urls from the last firefox sessionstore.js file used.

2010-03-29 0 min read Linux
\"Effective
Image via Wikipedia

Some taken from commandlinefu. What all the below commands are doing is basically that the url: is captured from the sessionstore.js file and then just  extract the URL from the line. These are done in various ways using perl, <a class="zem_slink freebase/en/sed" title="Sed" rel="wikipedia" href="http://en.wikipedia.org/wiki/Sed">sed and <a class="zem_slink freebase/en/awk" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk:

Continue reading
Older posts Newer posts