This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Import sys,getopt is having issue while taking inputs
Type: Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, venkata suresh gummadillli
Priority: normal Keywords:

Created on 2015-06-10 19:42 by venkata suresh gummadillli, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg245142 - (view) Author: venkata suresh gummadillli (venkata suresh gummadillli) Date: 2015-06-10 19:42
[@outsidetried ~]$ python 
[@outsidetried ~]$ python -h -i <input_file>
[@outsidetried ~]$ python -i hello.txt
Input JSON file provided for verification: hello.txt
[@outsidetried ~]$ python -i firstfile
Input JSON file provided for verification: firstfile
[@outsidetried ~]$ python -i <hello.txt>
-bash: syntax error near unexpected token `newline'
[sureshgv@outsidetried ~]$ python -i ??
Input JSON file provided for verification: ci
[@outsidetried ~]$ python -i ???
Input JSON file provided for verification: bf1
[@outsidetried ~]$ python -i $#@%
Input JSON file provided for verification: 0@%
[@outsidetried ~]$ cat 

import sys,getopt


def main(argv):
   inputfile = ''
      opts, args = getopt.getopt(argv,"hi:",["input_file="])
   except getopt.GetoptError:
      print ' -i <input_file>'
   for opt, arg in opts:
      if opt == '-h':
         print ' -i <input_file>'
      elif opt in ("-i", "--input_file"):
         inputfile = arg
   	 print 'Input JSON file provided for verification:', inputfile 
if __name__ == "__main__":
msg245143 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-06-10 19:47
This is not a problem with python, but rather with how bash interprets your program arguments. Try putting the arguments in single quotes, like:

python -i '$#@%'
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68616
2015-06-10 19:47:10eric.smithsetstatus: open -> closed

type: behavior ->

nosy: + eric.smith
messages: + msg245143
resolution: not a bug
stage: resolved
2015-06-10 19:42:08venkata suresh gummadilllicreate