Question

I am having an issue calling a command-line argument from inside a method.

This is a snippet from my script. In the first few operations, where the argument is passed as a method option/parameter, the argument value is correctly mapped. In the last operation, where the argument is called inside the method, the argument is passed as text. Is there a specific syntax I am missing to call the variable from inside a method?

# sets the command-line argument as a global variable
evidence_name = ARGV[0]

# The argument value (evidence_name)is successfully called below as an
# option/parameter
evidence = processor.newEvidenceContainer(evidence_name)
evidence.custom_metadata = { 'Barcode' => evidence_name }
evidence.addFile(evidence_path)
evidence.save

# Instead of calling the argument value (evidence_name), the method is
# reading evidence_name as text. So the script is searching for
# "evidence_name" and not the value that I specified from the command-line
# at runtime.
all_files = current_case.search('evidence-metadata:evidence_name AND contains-text:1')
Was it helpful?

Solution

Yes, you are missing string interpolation.

"evidence-metadata:#{evidence_name} AND contains-text:1"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top