• 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
78 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]#

78 comments:

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

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

    ReplyDelete
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. Thanks for sharing amazing information !!!!!!
    Please keep up sharing.

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

    ReplyDelete
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. 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
  39. 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
  40. 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
  41. 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
  42. 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
  43. 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
  44. 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.
    JAVA and J2EE Training Institute in Chennai | JAVA and J2EE Training Institute in Besant Nagar

    ReplyDelete
  45. I have read your blog. It’s very informative and useful blog. You have done really great job. Keep update your blog.
    Automation Anywhere Certification in Chennai | Automation Anywhere Training in Pallikaranai

    ReplyDelete
  46. Impressive blog with lovely information. Really very useful article for us thanks for sharing such a wonderful blog...
    RPA Training in Chennai | RPA Training in Madipakkam

    ReplyDelete