Scripts to create logins from bash command – for creating multiple accounts

2010-06-09 1 min read Fedora Linux

Heres the script:

cat «EOF > login.sh
for i in  `cat logins` ; do
login=`echo ”$i”|awk -F”:” '{print $2}’`;
comment=”`echo ”$i”|awk -F”:” '{print $1}’`”;
gr=”`echo ”$i”|awk -F”:” '{print $3}’`”;
echo ”login –» $login –Comment –» $comment  –Group –»$gr  –”;
echo ”useradd -c ”$comment” -d /export/home/$login -m -g $gr -s /bin/bash $login”
useradd -c ”$comment” -d /export/home/$login -m -g $gr -s /bin/bash $login
done

You would need to create file called logins to store the comment, login name and the group. The group must have already been created. Here is an example of the file:

Continue reading

Browser or User agent identification with php.

2010-06-09 1 min read Linux

<a href="http://apptools.com/phptools/browser/source.php">Link

This is a link to very nice code to identify the browser used by the user. I have put a test program with this <a href="http://amit-agarwal.co.in/find_browser.php">here.<a class="performancingtags" href="http://technorati.com/tag/browser" rel="tag">

How To Run Subscriber-Only Competitions on Your Blog

2010-06-08 0 min read Linux
\"I\'m
Image by catspyjamasnz via Flickr

A Guest Post by David Cleland from TotalApps.

In 2006 I proudly started my first blog, DigMo! It was <a class="zem_slink freebase/guid/9202a8c04000641f800000000003ac3a" title="Technology" rel="wikinvest" href="http://www.wikinvest.com/industry/Technology">technology, it was creativity, it was music and it was <a class="zem_slink freebase/guid/9202a8c04000641f80000000000141ab" title="Education" rel="wikipedia" href="http://en.wikipedia.org/wiki/Education">education. Despite it being a bit of blog soup I was pleased at how quick the site grew but within a few years it reached a critical point beyond which I really couldn’t get the traffic to grow. The site was frankly far too general to appeal to a specific community.

Continue reading

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

The best in command line xml: XMLStarlet

2010-06-08 1 min read Linux

<a href="http://bashcurescancer.com/the-best-in-command-line-xml-xmlstarlet.html">Quite some time ago I wrote about using xsltproc to process xml on the command line. Thank fully someone pointed out XMLStarlet.? I now use XMLStarlet almost every day.? I work with a variety of REST based API&#8217;s gather information. XMLStartlet along with a simple for loop or xargs gives …

If you are on fedora then you can use xmlstarlet in the following way. First install the package:

Continue reading

Verify all the paths in the PATH directory

2010-06-08 1 min read Bash Learning Linux

Here is the command to test that all the directories in your path actually exist.

(<a class="zem_slink freebase/en/internal_field_separator" title="Internal field separator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Internal_field_separator">IFS=:;for p in $PATH; do test -d $p || echo $p; done)

And the explanation :

Set the IFS to &#8221;:&#8221;

now we loop through the PATH variable

and test all the directories with &#8221;test -d&#8221;

Here is another version without IFS:

for i in ${PATH//:/ };do test  -d $i || echo $i;done

Continue reading

bash completion not working on Fedora

2010-06-06 1 min read Bash Fedora Linux

I had bash completion installed and after that I had made huge changes to my bashrc and also installed bashstyle. After this the bash-completion stopped working.

I had to spend a lot of time to figure out that the easiest solution was to source the bash-completion again in the end. 🙂

. /etc/bash_completion

Older posts Newer posts