Closed cookie33 closed 5 years ago
create 2 handles:
[irodstest2.storage.surfsara.nl]:/tmp
robertv$ irule -F /tmp/msiPidCreate.r "*path='/igor/testB2SafeCmd/1'" "*key_values_inp='CHECKSUM,12345,AAP,noot'"
0
21.T12996/250369cf-ce3d-4da0-a1bf-e0980096f7d3
[irodstest2.storage.surfsara.nl]:/tmp
robertv$ irule -F /tmp/msiPidCreate.r "*path='/igor/testB2SafeCmd/1'" "*key_values_inp='CHECKSUM,12345,AAP,noot'"
0
21.T12996/e43554ae-b075-4090-806f-721159978996
The script to do this is:
myRule {
if(strlen(*key_values_inp) > 0)
{
*key_values = split(*key_values_inp, ",");
}
else
{
*key_values = "";
}
*err = errorcode(msiPidCreate(*path,*key_values,*handle));
writeLine("stdout", *err);
writeLine("stdout", *handle);
}
INPUT *path="", *key_values_inp=""
OUTPUT ruleExecOut
Searching shows:
[irodstest2.storage.surfsara.nl]:/tmp
robertv$ irule -F /tmp/msiPidLookupKey.r "*key='URL'" "*value='*/igor/testB2SafeCmd/1'"
0
21.T12996/250369CF-CE3D-4DA0-A1BF-E0980096F7D3
21.T12996/E43554AE-B075-4090-806F-721159978996
[irodstest2.storage.surfsara.nl]:/tmp
robertv$
So there is an empty extra line in the output. The script to do this is:
myRule {
*err = errorcode(msiPidLookupKey(*key, "*value", *handles));
writeLine("stdout", *err);
foreach(*handles) {
writeLine("stdout", *handles);
}
}
INPUT *key="", *value=""
OUTPUT ruleExecOut
The curl search returns:
[irodstest2.storage.surfsara.nl]:/tmp
rods$ curl -u "username:<password>" "https://<fqdn>:<port>/hrls/handles/21.T12996?URL=*/igor/testB2SafeCmd/1"
["21.T12996/250369CF-CE3D-4DA0-A1BF-E0980096F7D3","21.T12996/E43554AE-B075-4090-806F-721159978996"]
It seems it is an artefact of my iRODS installation:
Use following script:
[irodstest2.storage.surfsara.nl]:/tmp
robertv$ cat /tmp/test.r
myRule {
*l=list("a", "b");
foreach(*l) {
writeLine("stdout", *l)
}
}
OUTPUT ruleExecOut
produces next output:
[irodstest2.storage.surfsara.nl]:/tmp
robertv$ irule -F /tmp/test.r
a
b
[irodstest2.storage.surfsara.nl]:/tmp
robertv$
So with an extra line.
[irodstest2.storage.surfsara.nl]:/tmp
robertv$ irule -F /tmp/test.r | wc -l
2
[irodstest2.storage.surfsara.nl]:/tmp
robertv$
Need to test some more...
It seems a setting of the session. The PS1
parameter might cause it.
Or it might be the test. It does in python:
def subprocess_popen(cmd, input_string=None):
'''run shell command, get output back in an array'''
process = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
(data_stdout, data_stderr) = process.communicate(input_string)
process.wait()
if data_stderr != None:
# relay errors to stderr
sys.stderr.write(data_stderr)
arr = string.split(data_stdout, '\n')
arr = map(string.strip, arr)
return arr
What if it adds here standard a \n
? Even if not needed
Fixed testcode:
def subprocess_popen(cmd, input_string=None):
'''run shell command, get output back in an array'''
process = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
(data_stdout, data_stderr) = process.communicate(input_string)
process.wait()
if data_stderr != None:
# relay errors to stderr
sys.stderr.write(data_stderr)
arr = string.split(data_stdout, '\n')
arr = map(string.strip, arr)
if arr and arr[-1] == '':
arr.pop()
return arr
The test shows following:
It shows an extra empty line when shows matching handles:
Can the extra line be removed?