I do have a stupid problem with quoting in a shell script. At least I
tend to think that the problem relates to quoting :-)
What I need: a python script should be called indirectly using a shell
script. The command line arguments are one to multiple file names and
should be handles correctly by the python script.
Following example demonstrates my problem:
,----[ directly calling the python scrip works ]
| vk@gary ~2d/mytest % ./mypy.py *png
| args: ['2012-08-01 this is with spaces 2.png', '2012-08-01 this is with spaces.png']
| press ENTER
| vk@gary ~2d/mytest %
`----
Calling the python script via a shell script does not work. The file
names containing spaces are being split up:
Opening a gnome-terminal is a requirement of my use case. It can be
replaced by any other terminal emulation if necessary.
»xterm -e /home/vk/tmp/2del/mytest/mypy.py ${@}« does not work either.
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
08-18-2012, 08:03 PM
Nils Kassube
Script-arguments with spaces
Karl Voit wrote:
> I do have a stupid problem with quoting in a shell script. At least I
> tend to think that the problem relates to quoting :-)
>
> What I need: a python script should be called indirectly using a
> shell script. The command line arguments are one to multiple file
> names and should be handles correctly by the python script.
>
> Following example demonstrates my problem:
>
> ,----[ directly calling the python scrip works ]
> | vk@gary ~2d/mytest % ./mypy.py *png
> | args: ['2012-08-01 this is with spaces 2.png', '2012-08-01 this is
> | with spaces.png'] press ENTER
> | vk@gary ~2d/mytest %
> `----
>
> Calling the python script via a shell script does not work. The file
> names containing spaces are being split up:
>
> ,----[ ./test.sh *png ]
> | args: ['2012-08-01', 'this', 'is', 'with', 'spaces', '2.png']
> | press ENTER
> `----
> Here are the scripts used above:
>
> ,----[ test.sh ]
> | #!/bin/bash
> | /usr/bin/gnome-terminal -e "/home/vk/tmp/2del/mytest/mypy.py ${@}"
> | #end
> `----
>
> Opening a gnome-terminal is a requirement of my use case. It can be
> replaced by any other terminal emulation if necessary.
> »xterm -e /home/vk/tmp/2del/mytest/mypy.py ${@}« does not work
> either.
Well, I'm not familiar with gnome-terminal but with xterm this should
work:
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
08-18-2012, 11:37 PM
Karl Voit
Script-arguments with spaces
Hi Nils!
* Nils Kassube <kassube@gmx.net> wrote:
> Karl Voit wrote:
>> /usr/bin/gnome-terminal -e "/home/vk/tmp/2del/mytest/mypy.py ${@}"
>> xterm -e /home/vk/tmp/2del/mytest/mypy.py ${@}
>
> Well, I'm not familiar with gnome-terminal but with xterm this should
> work:
>
> #!/bin/bash
> /usr/bin/xterm -e /home/vk/tmp/2del/mytest/mypy.py "$@"
Yes! :-)
Thanks for your input!
The reason why I did not tried this one was that I thought that the
argument after «-e» has to be quoted to be recognized as one
single argument. I was wrong with this assumption when using xterm.
In xterm, «-e» has to be the *last* argument. This way, it is able
to do the trick as shown by your email.
For anybody who wants to do this with gnome-terminal as well: there
is an additional option «-x» which takes *remaining* command line as
one single argument just like the «-e» option of xterm does.
Annoying problem for me for too long but now I got it, thanks!
--
Karl Voit
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users