Python Forum
error: unrecognized arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error: unrecognized arguments
#3
if __name__ == '__main__':
   ## Setup and parse command line arguments
   parser = argparse.ArgumentParser(prog='pemail.py', description='Sends an email with an attachment.')
   parser.add_argument('-f', '--frm', default='[email protected]', help='The sender address.')
   parser.add_argument('-t', '--to', help='The recipient address.')
   parser.add_argument('-s', '--subject', help='The subject of the email.')
   parser.add_argument('-b', '--body', help='The body of the email.')
   ##parser.add_argument('-b', '--body', type=str, required=True)
   parser.add_argument('-a', '--attachment', help='The path to the attachment.')

   args=parser.parse_args()

   pemail(args)

hi Wavic
I am passing following command to the function

there is some issue passing parameter s_body="test kajdsfkj"
------------------

#!/bin/sh

s_email='[email protected]'
s_body="test kajdsfkj"
s_attachment='/tmp/test3.txt'
python pemail.py -t $s_email -s $s_subject -b $s_body -a $s_attachment > /home/xxx/mytest/logs/email.$(date +"%Y%m%d%H%M%S").log

User has been warned for this post. Reason: didnt use code tags directly after getting a warning
Reply


Messages In This Thread
error: unrecognized arguments - by zafar202 - Feb-08-2017, 02:29 PM
RE: error: unrecognized arguments - by wavic - Feb-08-2017, 02:38 PM
RE: error: unrecognized arguments - by zafar202 - Feb-08-2017, 02:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 1,961 Oct-17-2022, 06:29 PM
Last Post: paulo79
  invalid keyword arguments error sagpal 3 2,417 Jun-04-2020, 10:24 PM
Last Post: bowlofred
  Function / Arguments / Error Help Ghosty 8 4,380 Jul-01-2018, 10:35 AM
Last Post: buran
  Pip apparently installed but unrecognized by CMD diegoctn 13 9,373 Apr-05-2018, 02:55 PM
Last Post: snippsat
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,886 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020