User Input as Password in Python

Hi Guys,

Probably, we can know how to get an input from user using raw_input(); Like in some cases we have to get input from user in authentication process at that time we might be a get user password from user. If user enters the password means it should be invisible to others for that there is an option to get the input depending to password.

We have to import a library called getpass With the help of this library we can get the user input as password. Examples are as follows.


import getpass
pw=getpass.getpass("Enter Your Password Here: ")
if (pw=="password"):
print "You are Welcome..."
else:
print "Sorry! Your are not allowed."

Copy this Code and Paste it in any text editor with file extension of .py; If you execute the code means the terminal waits for user input at “Enter Your Password Here: ” here if you type your password it is invisible to you but it has been storing your password into variable name called pw. After then it has been processed with the string for further Statements. If the condition true means True statements executed other wise false statement will executed.

Output:

password inputIn the figure you can see that cursor waits for user input.

bala@bala-desktop:~$ python pass.py
Enter Your Password Here:
You are Welcome.

Hope that these information is useful for you. 🙂

Thank You. 🙂

With Regards,
V. Balakrishnan.

Advertisements

CSS Preparation

Hello Friends,

Today i decided to learn about CSS, i didn’t not have any idea about CSS. I only know that CSS stands for Cascading Style Sheets, today only i started to learn from same W3schools tutorial really it is super for beginner to any language. However, now i can know How to use CSS in HTML, why it is using, How we can use it as in effective manner like few things. Today also i have attended that CSS quiz in that I have secured 95% (i.e) 19  out of 20

CSS quiz: http://www.w3schools.com/quiztest/quiztest.asp?qtest=CSS

my test paper

In CSS am having a doubt that can we specify the size of background image like doing in html body attribute itself. Like that is it possible to change the background image size. I used height and width attribute but i failed to did. Can any one means kindly comment it…. 🙂

Thank You.

With Regards,
V. Balakrishnan.

HTML Preparation

Hi friends,

I have already know little about HTML and to where it is used, why it is used. I decided to learn more and steady in HTML my brother Arulalan told me to go through from W3schools tutorial. As per his advice yesterday i started to learn more about HTML and attended the HTML quiz which is performed in w3schools site itself. I have scored 90% marks (i.e) 18 out of 20.

HTML Quiz: http://www.w3schools.com/quiztest/quiztest.asp?qtest=HTML

My Certificate:

my html test paper

But Still am having doubt about Meta tag and doc type. I didn’t know how to generate Doc type whether we have to do it manually or any shortcut or procedure is available to insert that doc type, i don’t know about that. Another one is about meta tag as i understood that meta tag is only for server’s knowing isn’t. If anybody knows about these two things kindly give an idea. 😉

Thank You,

With Regards,
V. Balakrishnan

Searching and Removing Files using 1 command

Hello Friends,

Today I used my USB stick in friend system, he having windows OS in his system. After used in that system my USB stick contains of lot of .exe files (May be VIRUS). When i used it my Ubuntu PC i founded that it is unwanted to me so i decided to delete it. I removed it in 2 folders manually then only i decided to remove it automatically using Linux commands.

I tried it with list, search and remove commands,  ls, grep, rm respectively. But i failed to do that i can search and list all the files that have extension called .exe using the command

bala@bala-desktop:/media/KRISH$ ls -R | grep “.exe”
bala .exe
Aptitude .exe
Project .exe
connection .exe
waste .exe
tabtoenter .exe
wholemodule-change .exe
Resume updt 05-03-11 .exe
Resume .exe
Scanned Documents .exe
Screen Cast .exe
Vid Tut .exe

If i add the remove command means its not worked

bala@bala-desktop:/media/KRISH$ ls -R | grep “.exe” | rm -rf

Again I tried using

bala@bala-desktop:/media/KRISH$ ls -R | grep “.exe” | rm -r *.exe

This time i can delete files in the current directory only. My aim is to delete all folders and sub folders in the USB. Finally i decided to google for this and get the solution as i expected. I would like share here…

bala@bala-desktop:/media/KRISH$ find . -name “*.exe” -exec rm -i {} \;
rm: remove regular file `./bala/connection/connection .exe’? y
rm: remove regular file `./bala/waste/waste .exe’? y
rm: remove regular file `./bala/Project/Project .exe’? y
rm: remove regular file `./bala/tabtoenter/tabtoenter .exe’? y
rm: remove regular file `./bala/wholemodule-change/wholemodule-change .exe’? y
rm: remove regular file `./bala/Aptitude/Aptitude .exe’? y
rm: remove regular file `./bala/bala .exe’? y
rm: remove regular file `./Resume updt 05-03-11/Resume updt 05-03-11 .exe’? y
rm: remove regular file `./Resume updt 05-03-11/Resume/Resume .exe’? y
rm: remove regular file `./Scanned Documents/Scanned Documents .exe’? y
rm: remove regular file `./Screen Cast/Screen Cast .exe’? y
rm: remove regular file `./Vid Tut/Vid Tut .exe’? y

By using the above command we can remove the file with user confirmation (y or n). Otherwise we can also use

bala@bala-desktop:/media/KRISH$ find . -name “*.exe” -exec rm -i {} \;

With this command we can remove tons of files in any format using single command in fraction of seconds.
Caution: Before removing file makes sure, you have backup of all-important files. Do not use rm command as root user it can do critical damage to Linux system.

Enjoy on removing files…. Ha ha 😉

Thank You.

With Regards,
V. BalaKrishnan.