get all the urls in html file (local or on server).

2014-02-17 1 min read Bash Fedora

To use this, you will need the lynx tool, so install that first.

sudo yum install lynx

Now, to get list of all the URLs in local html file or some URL, just execute this:

lynx -dump -listonly

 

Continue reading

Home grown mail scheduler with bash script and cron

2013-10-04 2 min read Bash Linux

If you are using Linux (Fedora/Ubuntu or anything else) then you do get a lot of tools and one of them is cron. Very very useful. Just write some script that can do the task for you, put it in cron and forget it. So, here is a home grown way to schedule mails.

First, copy this script below:

#!/bin/bash -
#===============================================================================
#
#          FILE: sched_mail.sh
#
#         USAGE: ./sched_mail.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka), 
#      REVISION:  ---
#===============================================================================

mailfile="~/mail"
if [[ $(wc -l $mailfile|awk '{print $1}' ) -ge 5 ]]
then
    to=$(grep ^To: $mailfile|sed 's/To: //')
    echo "Good to send mail... to = $to"
    sendmail -t <$mailfile
    echo "once mail is send, delete the contents of file"
    echo "sed -i '4,$ d' $mailfile"
fi

Now, create a file called mail in your home directory, with the following contents:

Continue reading

xmlwf – Is your xml document well formed?

2012-02-18 1 min read Bash

There is a small nifty utility called xmlwf that can check your xml documents to see if they are well formed.

sudo yum install expat

Once installed, simply use :

xmlwf

Need more details, just check the man page 🙂

Enhanced by Zemanta

client lanman auth is disabled error for samba

2011-04-28 1 min read Learning Linux

The error:

Server requested LANMAN password (share-level security) but ‘client lanman auth’ is disabled

is easily fixable. You just need to tell samba that client lanman auth is enabled. And here is how to do this:

If you are getting this error then add the following in the globals section of the samba configuration:

client lanman auth = Yes

 

Ensure that you change this in the file /etc/samba/smb.conf

Continue reading

configuration for afraid-dyndns on Fedora and other similar distro.

2011-03-04 1 min read Fedora Linux

First install afraid-dyndns with the command:

  <td>
    <div class="text codecolorer">
      sudo yum install afraid-dyndns
    </div>
  </td>
</tr>
1

Now open the configuration file /etc/afraid-dyndns.cfg and we need to change the following:

Notify = root@localhost # leave empty to suppress notifications
CacheFile = /var/cache/afraid-dyndns/IP
AccountHash =

For the Account hash, head over to http://freedns.afraid.org/api/ login and then click one of the XML or the ASCII links there. Once the page has loaded, look at the URL which is of form:

Continue reading

print every nth line

2011-03-01 2 min read Bash Linux

Some time back I was working with lot of data and wanted to analyze only the every 10 line sometimes and sometimes every 20th line. I had to keep doing these changes in vim or otherwise so finally I wrote a program to do this for me. If you need such a program then here it is:

  <td>
    <div class="text codecolorer">
      #!/bin/bash -<br /> #===============================================================================<br /> #<br /> #          FILE:  print_nth_line.sh<br /> #<br /> #         USAGE:  ./print_nth_line.sh<br /> #<br /> #   DESCRIPTION:  Print every nth line<br /> #<br /> #       OPTIONS:  ---<br /> #  REQUIREMENTS:  ---<br /> #          BUGS:  ---<br /> #         NOTES:  ---<br /> #        AUTHOR:   (),<br /> #       COMPANY:<br /> #       VERSION:  1.0<br /> #       CREATED:  12/08/2010 05:36:53 PM IST<br /> #      REVISION:  ---<br /> #===============================================================================<br /> <br /> if [ x"$1" == "x" ]<br /> then<br /> echo "Please provide the line numbers to print .. .ex 3 will print 3,6,9"<br /> exit -1;<br /> fi<br /> if [ x"$2" == "x" ]<br /> then<br /> echo "Please provide the filename"<br /> exit -2;<br /> fi<br /> awk 'temp++ { if ( temp % '$1' == 0) print $1};' $2
    </div>
  </td>
</tr>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Enhanced by Zemanta

analyze debug queries output for wordpress

2011-02-09 2 min read Wordpress

Some time back, my website became too slow and I started getting timeout response for quite a lot of my pages. When I analyzed things, I found the issue was with the DB queries taking a lot of time. So, I thought of getting my hands dirty and started with installing the plugin “Debug Queries”. Just in case, you don’t know about the plugin, it lists all the queries to DB along with the time taken for the query when a Admin user visits any page.

Continue reading
Older posts