Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

12
  • This question is really "how do I pass strings to a python program" (and it's not done the way you do it), and it's honestly a programming question. To make this really short: you want to use command line arguments, or passing in textual data through standard input. Both is well-documented for Python! Commented Apr 14, 2023 at 15:35
  • 1
    People: Please don't vote to migrate on topic questions. This is 100% on topic here and should not be migrated. Commented Apr 14, 2023 at 15:53
  • 1
    @MarcusMüller python is a standard tool used to administer *nix systems and this is not a question about string literals, it's about "how do I get my *nix system to work with this" and that is on topic. Commented Apr 14, 2023 at 15:59
  • 1
    @MarcusMüller the main issue here is about the shell, python is incidental. The reason it doesn't work is because the variable is expanded by the shell before python ever sees it, so python ends up seeing an unquoted string literal. So it really is about how the shell and python interact. If this had been presented as a python script, that could arguably be off topic, but a one-liner is essentially a *nix command, so... Commented Apr 14, 2023 at 16:05
  • 1
    Oh, and to clarify, I have no more "authority" about what is on topic than anyone else. Mods don't decide that, the community does. Mods do tend to be very familiar with the scope, that much is true, but that doesn't mean I'm right just because I'm a mod! Commented Apr 14, 2023 at 16:06