Python Forum
Problems passing arguments containing spaces to bash script and then on to python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems passing arguments containing spaces to bash script and then on to python
#1
I am a definite newbie to python. I've written some pretty basic programs that use shell scripts to pass user supplied arguments to my python programs. The problem I have now is that several of my parameters have spaces (for example an address line might read something like '1116 E. State St.'). The python program just parses the list of arguments each with one word. So my address line would be 4 arguments. I've tried single quotes, double quotes, three single ('''1116...'''), three double ("""1116..."""), and combinations of each of those. How do I pass my parameters as needed?

My shell program is attached.

This is the error I get:
(v398) -bash5.2 /home/opensource/pysrc/tst/RepEmploymentVerification $ rep_employment_verification.sh tst 1 kaustin Richard Green 123-45-6789 He Him Cutco ''''State Street'''' Olean NY 14760 Karen 585-968-1497 Jan12020 N Feb1202 N Feb22015 00004
---------------------------
** tst (tst) ENV LOADED **

Traceback (most recent call last):
File "/home/opensource/pysrc/tst/RepEmploymentVerification/./rep_employment_verification2.py", line 474, in <module>
scriptName, environment, letterType, userName, firstName, lastName, socSecNumber, pronoun, pronoun2, companyName, address, city, state, zip, attention, faxNumber, lastActiveDate, lastActiveDateFlag, lastOrderDate, lastOrderDateFlag, contractDate, company = argv
ValueError: too many values to unpack (expected 22)

Attached Files

.txt   rep_employment_verification.txt (Size: 2.46 KB / Downloads: 29)
Reply


Messages In This Thread
Problems passing arguments containing spaces to bash script and then on to python - by kaustin - Apr-03-2024, 03:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Passing writable arguments to functions. Assembler 11 1,235 Jan-15-2024, 11:32 PM
Last Post: sgrey
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 831 Dec-04-2023, 09:48 PM
Last Post: sanky1990
  How do I handle escape character in parameter arguments in Python? JKR 6 1,442 Sep-12-2023, 03:00 AM
Last Post: Apoed2023
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,673 Jun-29-2023, 11:57 AM
Last Post: gologica
  math formula does not give the same result as bash script [SOLVED] AlphaInc 3 1,069 Apr-02-2023, 07:21 PM
Last Post: AlphaInc
Question log.exception() without arguments in old Python versions? cthart 5 1,316 Nov-19-2022, 07:09 PM
Last Post: Gribouillis
  Passing string functions as arguments Clunk_Head 3 1,348 Jun-15-2022, 06:00 AM
Last Post: Gribouillis
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 6,904 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning
  Call a bash script from within a Python programme Pedroski55 6 2,582 Dec-06-2021, 01:53 PM
Last Post: DeaD_EyE
  Showing and saving the output of a python file run through bash Rim 3 2,633 Oct-06-2021, 10:48 AM
Last Post: gerpark

Forum Jump:

User Panel Messages

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