Forum

Author Topic: how to input arguments to a script  (Read 4931 times)

michaelzhangxc

  • Newbie
  • *
  • Posts: 13
    • View Profile
how to input arguments to a script
« on: April 07, 2014, 06:08:45 PM »
I tried to input arguments to a script through Run Python Script dialogue window, but failed. The code is is as below:

AA=input('input argument AA:')
print (AA)

bb=input('input argument bb:')
print (bb)



Reffer the attached picture.

Console message:
Traceback (most recent call last):
  File "C:/Python33/try.py", line 4, in <module>
    AA=input('input argument AA:')
RuntimeError: input(): lost sys.stdin

Anyone can help? Thanks in advance.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14004
    • View Profile
Re: how to input arguments to a script
« Reply #1 on: April 07, 2014, 06:21:06 PM »
Hello michaelzhangxc,

You need to use sys module to access arguments:

Code: [Select]
import PhotoScan
import sys

input = sys.argv[1]

print(input)

Please note that "input" variable is string.
Best regards,
Alexey Pasumansky,
Agisoft LLC

michaelzhangxc

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: how to input arguments to a script
« Reply #2 on: April 07, 2014, 07:11:21 PM »
that was quick Alexey, thank you. Now it works perfect.