0

I have a simple executable python script saved like /usr/local/bin/OscStr, which requires a file like an argument. I can call it with the terminal from anywhere. But when I try $OscStr *.log it takes only one .log file.

Does wildcard work like a for loop or does it give multiple arguments to a command?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Juicce
  • 33
  • 5
  • 3
    this is a bash question more than a python question. *.log will be expanded to every matching file in the current dir e.g. to `$ OscStr a.log b.log` – joel Mar 12 '19 at 19:45
  • Yes, so the script takes multiple arguments and it should be ready for that. Thanks. – Juicce Mar 12 '19 at 19:50
  • Does it only *get* one log file, or does it only try to *use* the first log file? What are the contents of `sys.argv`? – chepner Mar 12 '19 at 19:52
  • @AdamSrut, one place you can start is running `set -x` to tell the shell to log every command it runs -- that way you'll actually *see* the log filenames instead of the glob expression itself being passed to the python interpreter. – Charles Duffy Mar 12 '19 at 19:55
  • see https://stackoverflow.com/q/31733193/5986907 for `sys.argv` – joel Mar 12 '19 at 19:59
  • also see https://stackoverflow.com/q/14155669/5986907 – joel Mar 12 '19 at 20:02
  • @chepner It takes only first .log file from sys.argv. So there will be the problem. Script now can take all the arguments from sys.argv so I solved the problem. – Juicce Mar 12 '19 at 20:21

0 Answers0