password special character $ is not taking taking by argpars

This is the place for queries that don't fit in any of the other categories.

password special character $ is not taking taking by argpars

Postby appollosputnik » Mon Aug 26, 2013 12:32 pm

I am trying to enter user name and password from command line. user name is [removed] and password is [removed].....When I am printing this values I can see the password is wrong. I am typing [removed] but it is printing [removed]. $ and 3 are discarded.....Please help me what is going wrong.why it is not taking special character $?....Most of my passwords are having '$' sign. Please help.
Code: Select all
__author__ = 'sujan'
#!/usr/bin/python

import argparse
import sys

def main(argv):
    parser = argparse.ArgumentParser(description='Description of your program')
    parser.add_argument('-u', '--usr', help='UserName', required=True)
    parser.add_argument('-p', '--pswd',help='PassWord', required=True)
    args = vars(parser.parse_args())
    uname = args['usr']
    # code here

    password =  args['pswd']
    # code here

    if uname is None or password is None:
        print "User name - Password not valid"
    else:
        print uname
        print password
        print "calling program"

if __name__ == "__main__":
   main(sys.argv[1:])
Last edited by Mekire on Mon Aug 26, 2013 2:26 pm, edited 1 time in total.
Reason: Email and password removed from post. I'm hoping they were hypothetical, but just in case.
appollosputnik
 
Posts: 7
Joined: Tue Aug 06, 2013 9:13 am

Re: password special character $ is not taking taking by arg

Postby stranac » Mon Aug 26, 2013 12:44 pm

$3 has a special meaning for the shell.
Try putting the password in quotes.
I think using a \ to escape the $ might also work.

Also, I believe the shebang line(the one starting with #!) must be the first line of the file, else it does nothing.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: password special character $ is not taking taking by arg

Postby appollosputnik » Mon Aug 26, 2013 1:55 pm

Thanks a lot my dear friend. quote did work. Thanks Sujan
appollosputnik
 
Posts: 7
Joined: Tue Aug 06, 2013 9:13 am


Return to General Coding Help

Who is online

Users browsing this forum: snippsat and 2 guests