• Welcome to Bashguru

    Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. It's functionality list is quite similar to that of UNIX and become very popular over the last several years. Our Basic motive is to provide latest information about Linux Operating system.

  • Python Programming

    Python is a comparatively simple programming language, compared to c++. Although some of the benefits of c++ are abstracted away in python, they are replaced with an overall easier to learn language with many “intuitive” features. For this reason it is common and recommended by most professionals that people new to programming start with python.

  • Perl Programming

    Perl is an open-source, general-purpose interpreted programming language. Used often for CGI, Perl is also used for graphics programming, system administration, network programming, finance, bioinformatics, and other applications. The Perl languages borrow features from other programming languages including C, shell scripting (sh), AWK, and sed. They provide powerful text processing facilities without the arbitrary data-length limits of many contemporary UNIX command line tools, facilitating easy manipulation of text files.

  • Android

    Android is an operating system based on the Linux kernel, and designed primarily for touch screen mobile devices such as smart phones and tablet computers. Android is a Linux-based software system, and similar to Linux, is free and open source software. This means that other companies can use the Android operating developed by Google and use it in their mobile devices.Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.

Saturday, September 19, 2009

Posted by venu k
120 comments | 10:33 AM

#!/bin/bash
# isuserloggedin.sh
# Usage: isuserloggedin.sh username
# Shell script which checks after every one minute whether a user has logged in
# or not
# You can also run script in background using & then foreground it to view result

if [ $# -ne 1 ]
then
echo "You supplied wrong arguments"
echo "usage : `basename $0` username"
exit 1
fi

isuserexist()
{
grep -w "$1" /etc/passwd > /dev/null

if [ $? -eq 1 ]
then
echo "$1 is not a valid user"
exit 1
fi
}

isuserexist $1
time=0
while true
do
# you can replace following two statements with
# if `who|grep $1 > /dev/null`
who|grep $1 > /dev/null
if [ $? -eq 0 ]
then
echo "User $1 is logged in "
if [ $time -gt 60 ]
then
hours=$((time/60))
minutes=$((time%60))
echo "He is logged in $hours hour(s) $minutes minute(s) late"
else
echo "He is logged in $time minute(s) late"
fi
exit 0

else
let time++

# You can use following formats also
# time=`expr $time + 1 `
# time=$((time+1))

sleep 60
fi
done

Output:
[root@localhost shell]# sh isuserloggedin.sh
you have suplied wrong arguments
usage : isuserloggedin.sh username
[root@localhost shell]# sh isuserloggedin.sh root
User root is logged in
He is logged in 0 minute(s) late
[root@localhost shell]# sh isuserloggedin.sh roott
roott is not a valid user
Run script in background
[root@localhost shell]# sh isuserloggedin.sh venu &
[1] 15917
[root@localhost shell]# User venu is logged in
He is logged in 3 minute(s) late

[1]+ Done sh isuserloggedin.sh venu
Run script in background then foreground it
[root@localhost shell]# sh isuserloggedin.sh venu &
[1] 16223
[root@localhost shell]# fg
sh isuserloggedin.sh venu
User venu is logged in
He is logged in 1 minute(s) late
[root@localhost shell]#

120 comments:

  1. There are lots of information about latest technology and how to get trained in them, like UNIX Training have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies(UNIX Training Institutes in Chennai). By the way you are running a great blog. Thanks for sharing this.

    UNIX Training | UNIX Training Institutes in Chennai

    ReplyDelete
    Replies
    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.

      Delete
  2. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    digital marketing course in Chennai | digital marketing training in Chennai

    ReplyDelete
  3. • such a good website and given to more information thanks! and more visit.
    selenium training in chennai

    ReplyDelete
  4. Thanks for sharing this valuable articles - Best QTP Training in Chennai
    Try it Yourself »

    ReplyDelete
  5. Extremely enlightening substance. Digital marketing is the best to promote our product. We mainly focus on SMO and SEO in digital marketing. The main task is to analyze the keyword and to bring the site at the top position for particular keyword.
    Digital Marketing Training in Chennai | Digital Marketing Chennai | Digital Marketing courses in Chennai

    ReplyDelete
  6. I have read your blog its very Interesting. Thanks for sharing. ERP Providers in Chennai | ERP in Chennai. We provide best quality cost effective ERP software applications and end to end enterprise solutions to all the industry verticals with the affordable cost.

    ReplyDelete
  7. Thank you for this valuable information. I have got some important suggestions from it. Get your business to the next level in simple steps.
    ERP in Chennai

    ReplyDelete
  8. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android training in chennai

    ReplyDelete
  9. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Ios training in chennai

    ReplyDelete
  10. http://sysacd.in/portfolio-view/red-hat-linux-training-in-chennai/
    http://sysacad.in/portfolio-view/linux-training-in-chennai/
    http://sysacad.in/portfolio-view/red-hat-linux-training-in-chennai/
    http://sysacad.in/portfolio-view/red-hat-virtualization-rhcva/
    http://sysacad.in/portfolio-view/shell-scripting-training-in-chennai/
    http://sysacad.in/portfolio-view/ibm-aix-system-administration/
    http://sysacad.in/portfolio-view/ibm-hacmp-powerha/

    ReplyDelete
  11. I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.

    Webdesign Lüdenscheid

    ReplyDelete
  12. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Java Training In Bangalore

    ReplyDelete
  13. Interesting post! This is really helpful for me. I like it! Thanks for sharing!
    online marketing lüdenscheid

    ReplyDelete
  14. The website is looking bit flashy and it catches the visitors eyes. A design is pretty simple .
    online marketing lüdenscheid

    ReplyDelete
  15. Thank you a bunch for sharing this with all of us you really understand what you are speaking about! Bookmarked. Please additionally seek advice from my website =). We can have a link trade arrangement among us!

    ReplyDelete
  16. Thanks for sharing amazing information !!!!!!
    Please keep up sharing.

    ReplyDelete
  17. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Best Hadoop Training Institute In chennai

    ReplyDelete
  18. Some us know all relating to the compelling medium you present powerful steps on this.Advanced Selenium Training in Chennai

    ReplyDelete
  19. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    aws training in Chennai

    ReplyDelete
  20. Best Mobility ServicesVery good informative article. Thanks for sharing such nice article, keep on up dating such good articles.

    ReplyDelete
  21. I and my friends were going through the nice, helpful tips from the blog then the sudden came up with an awful suspicion I never expressed respect to the website owner for those secrets.
    amazon-web-services-training-in-bangalore

    ReplyDelete
  22. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site. JAVA Training in chennai

    ReplyDelete
  23. I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
    Best selenium training Institute in chennai

    ReplyDelete
  24. Madhuvahini Houseboat Service is the new initiative being launched by Malabar tourism management @ Bekal, Nileshwar, Kasaragod, Kannur, Calicut, Manglore. 1HR, 2HR, Sunset, Dinner, Overnight, Day Night Cruise Available. Life is Better on Boats to explore the area of backwaters and offer Kerala traditional Home and Boat Stay Service.

    ReplyDelete
  25. Yiioverflow presenting one of the best and high performance PHP framework. Fast, secure and extremely professionals are developing applications. We guide to implement mobile app development and SOA hybrid applications.Code in Nodejs, Angular,Ionic,ReactJS and Yiiframework.

    ReplyDelete
  26. It is really great work and the way in which you are sharing the knowledge is excellent. Thanks for your informative article.
    Graphic Designing Training Course in Chennai | Graphic Designing Training Course in Velachery

    ReplyDelete
  27. It is really great work and the way in which you are sharing the knowledge is excellent. Thanks for your informative article
    No.1 UIPath Training Institute in Chennai | No.1 UIPath Training Institute in Velachery

    ReplyDelete
  28. Great post. Wonderful information and really very much useful. Thanks for sharing and keep updating.
    Graphic Designing Training Institute in Chennai | Graphic Designing Training Institute in Velachery

    ReplyDelete
  29. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    Blue Prism Robotic Process Automation in Chennai | Blue Prism Robotic Process Automation in Velachery

    ReplyDelete
  30. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    No.1 Microsoft Azure Training Institute in Chennai | No.1 Microsoft Azure Training Institute in Velachery

    ReplyDelete
  31. Awesome article.The information I have been searching precisely. It helped me a lot, thanks. Keep coming with more such informative article. Would love to follow them.
    Certified Ethical Hacking Training in Chennai | Blue Prism Training Institute in Chennai

    ReplyDelete
  32. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    Certified Ethical Hacking Training in Chennai | Certified Ethical Hacking Training in Velachery

    ReplyDelete
  33. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    CLOUD COMPUTING Classes in Chennai | CLOUD COMPUTING Courses in Velachery

    ReplyDelete
  34. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    Selenium Testing Course in Chennai | Selenium Testing Course in Velachery

    ReplyDelete
  35. It’s always so sweet and also full of a lot of fun for me personally and my office colleagues to search your blog a minimum of thrice in a week to see the new guidance you have got.
    No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Velachery | No.1 Blue Prism Training Institute in Kanchipuram

    ReplyDelete
  36. Pretty post. Whatever we accumulated data from the web journals, we ought to actualize that in basically then no one but we can comprehend that precise thing obviously.
    Automation Anywhere Training with Placement in Chennai | Automation Anywhere Training with Placement in Tambaram

    ReplyDelete
  37. My rather long internet look up has at the end of the day been compensated with pleasant insight to talk about with my family and friends.
    JAVA and J2EE Training Institute in Chennai | JAVA and J2EE Training Institute in Velachery

    ReplyDelete
  38. Hello there! This is my first comment here, so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles. Thanks.
    No.1 Automation Anywhere Training Institute in Chennai | No.1 Automation Anywhere Training Institute in Velachery

    ReplyDelete
  39. My rather long internet look up has at the end of the day been compensated with pleasant insight to talk about with my family and friends.
    UIPath Robotic Process Automation in Chennai | UIPath Training in Tambaram

    ReplyDelete
  40. Thanks for sharing this wonderful blog. Helpful article ! Kindly visit us @ Chocolate gift box

    ReplyDelete
  41. Hi, I am really happy to find such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post.
    No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Kanchipuram

    ReplyDelete
  42. Nice Blog… Wonderful Information and really very much useful. Thanks for sharing and keep updating…
    Python Training Institute in Chennai | Python Training Institute in Velachery

    ReplyDelete
  43. All the points you described so beautiful. Every time i read your blog content and i so surprised that how you can write so well.
    Hardware and Networking Training in Chennai | Hardware and Networking Training in Taramani

    ReplyDelete
  44. Nice Post! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep your blog as updated.
    Python Exam Centers in Chennai | Python Exam Centers in Chennai

    ReplyDelete
  45. Really it was an awesome blog...... Very interesting to read, .It’s very helpful for me, Big thanks for the useful info and keep updating…
    CCNP Training Institute in Chennai | CCNP Training Institute in Velachery

    ReplyDelete
  46. The provided information’s are very useful to me.Thanks for sharing.Keep updating your blog.
    Oracle Training in Chennai | Oracle Training in Kanchipuram

    ReplyDelete
  47. Really it was an awesome article...very interesting to read.. You have provided a nice article....Thanks for sharing..
    Blueprism Exam Center in Chennai | Blueprism Exam Center in Velachery

    ReplyDelete
  48. This is really too useful and have more ideas from yours. keep sharing many techniques and thanks for sharing the information.
    Best UIPath Training Institute in Chennai | Best UIPath Training Institute in Velachery

    ReplyDelete
  49. Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog….
    Best CCNA Training Institute in Chennai| CCNA Training Center in Velachery

    ReplyDelete
  50. Nice blog…. with lovely information. Really very useful article for us thanks for sharing such a wonderful blog. Keep updating…..
    Best Linux Training Institute in Pallikaranai| Best Linux Training Institute in Velachery

    ReplyDelete
  51. Nice blog…. with lovely information. Really very useful article for us thanks for sharing such a wonderful blog. Keep updating…..
    Best Linux Training Institute in Pallikaranai| Best Linux Training Institute in Velachery

    ReplyDelete
  52. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai

    ReplyDelete
  53. Awesome article…. Really very helpful information for us. Keep it up. Keep blogging. Looking to reading your next post,. Thank You for Sharing This Information
    Best PCB Training Institute in Taramani| Best PCB Training Institute in Velachery

    ReplyDelete
  54. Information from this blog is very useful for me, am very happy to read this blog Kindly visit us @ Christmas Gift boxes | Wallet Box

    ReplyDelete
  55. Good Post…. Thanks for the useful information it’s very useful to read your blog. Keep blogging article like this.
    Best JAVA/J2EE Training Institute in Perungudi| Best JAVA/J2EE Training Institute in Velachery

    ReplyDelete
  56. Nice blog, really I feel happy to see this useful blog… Thanks for sharing this valuable information to our vision....
    Best AWS Training Institute in Medavakkam| Best AWS Training Institute in Velachery

    ReplyDelete
  57. Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog….
    Blue prism Training in Chennai | Blue prism Training in Besant Nagar

    ReplyDelete
  58. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @
    Best Travels in Madurai | Tours and Travels in Madurai

    ReplyDelete
  59. Really wonderful post.... My sincere thanks for sharing very useful information to the users... Please continue to share this kind of post
    Best Python Exams Center in OMR| Best Python Certification Exams in OMR

    ReplyDelete
  60. Very informative blog. Thanks for sharing such good information and keep on updating.
    Automation Anywhere Training in Chennai | Automation Anywhere Training in Ashok Nagar

    ReplyDelete
  61. Wonderful blog… You provided very interesting information here. I feel happy to read this post. I hope that you will write many posts like this… Thanks for sharing and Keep updating…..
    Python Training Institute in Chennai | Python Training Institute in Velachery

    ReplyDelete
  62. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    UIPath Training in Chennai | UIPath Training in Kanchipuram

    ReplyDelete
  63. I have read your blog its very attractive and impressive. I like it your blog.
    Ethical Hacking Training in Chennai | Ethical Hacking Training in Thiruvanmiyur

    ReplyDelete
  64. Thanks for posting this useful content, Good to know about new things here,Keep updating your blog...
    Android Training in Chennai | Android Training in Porur

    ReplyDelete
  65. This is really too useful and have more ideas from yours. keep sharing many techniques. eagerly waiting for your new blog and useful information. keep doing more.
    Java Training in Chennai | Java Training in St.Thomas Mount

    ReplyDelete
  66. Nice blog. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    Blue prism Training in Chennai | Blue prism Training in Medavakkam

    ReplyDelete
  67. Your blog is really amazing with smart and cute content.keep updating such an excellent article..
    Software Testing Course in Chennai | Software Testing Course in Perungudi

    ReplyDelete
  68. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Best Ethical Hacking Training Institute in Chennai | Best Ethical Hacking Training Institute in Velachery

    ReplyDelete