Plink from within root

Dear colleagues

For my following question I tried to find a solution in other forums but didn’t get an answer so I try here because it has at least something to do with root.

From within my root macro I need to run a command on another linux machine. Therefore, I use “plink.exe” on my windows platform (it is part of putty) to exectue the command

system("plink delos@remote command something")

In detail the command looks like this:

system("plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -start "12/10/2016 00:00:00" -end "19/10/2016 00:00:00" -gnuplot -precision 9 /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2");

Somehow, plink cannot handle arguments especially when they contain quotation marks. The command “plink delos@host ArchiveExport” works without any arguments.
I tried to use (back)/slashes and so on but nothing is accepted.
Does any one of you have a clue what I could do?

best regards,
delos

stackoverflow.com/questions/3493 … nk-windows

Try first from the command prompt. Once it works, write it in your C++ script, you may need to add extra backslashes for each \ and ".

Dear ferhue

Sorry, I forgot to mention but of course I tried from the command prompt in windows first. Also there arguments don’t seem to be handed over.
It’s true, that it is more a windows or plink problem and not a root issue. But maybe someone finds a solution here.

Cheers,
delos

Try to go step by step and check at which point is failing:

From the command prompt:

plink delos@host /usr/local/bin/ArchiveExport
plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat
plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -gnuplot
plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -gnuplot -precision 9
plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -gnuplot -precision 9 /gfa/archiver-data/archive_ZHE_MT/index
plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -gnuplot -precision 9 /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:27
plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -gnuplot -precision 9 /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:27 -start '12/10/2016 00:00:00' -end '19/10/2016 00:00:00'

See also:
stackoverflow.com/questions/5772 … ble-quotes
groups.google.com/forum/#!topic … 0lGnbLIZxo

Hi

Actually, it works now from the windows command prompt. When I try a system call with system(“plink”) from within root it complains that ArchiveExport cannot be found.

Cheers,
delos

Could you be more explicit? What command did work for you from the command prompt?
How do you translate this command to a ROOT script? Do you add backslashes?
What is the exact error output?

Hi,

Try:

system("plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -start \\\"12/10/2016 00:00:00\\\" -end \\\"19/10/2016 00:00:00\\\" -gnuplot -precision 9 /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2");

For example, those two commands (remote processing a root macro):

root [2] gSystem->Exec("plink bellenot@bbcc7x64 source /build/bellenot/bin/root/master/bin/thisroot.csh; root -l -q 'rootdev/get_fs_info.C(\\\"/build/bellenot/rootdev\\\")'");
Processing rootdev/get_fs_info.C("/build/bellenot/rootdev")...
infos for /build/bellenot/rootdev id: 1481003842 bsize: 4096 blocks: 20968547 bfree: 11724607
root [3] system("plink bellenot@bbcc7x64 source /build/bellenot/bin/root/master/bin/thisroot.csh; root -l -q 'rootdev/get_fs_info.C(\\\"/build/bellenot/rootdev\\\")'");
Processing rootdev/get_fs_info.C("/build/bellenot/rootdev")...
infos for /build/bellenot/rootdev id: 1481003842 bsize: 4096 blocks: 20968547 bfree: 11724616
root [4]

Cheers, Bertrand.

Hi

I tried system("plink delos@host /usr/local/bin/ArchiveExport -o tmp.dat -start \\\"12/10/2016 00:00:00\\\" -end \\\"19/10/2016 00:00:00\\\" -gnuplot -precision 9 /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2");
but windows complains Der Befehl "ArchiveExport" ist entweder falsch geschrieben oder konnte nicht gefunden werden. The command is either incorrect or could not be found.
I dont understand why windows regards “ArchiveExport” as a command but not an argument.

Cheers,
delos

Hi,

Could you first try without argument? Something like:

system("plink delos@host /usr/local/bin/ArchiveExport");To see the output?

And try also:

system("plink delos@host ls -l /usr/local/bin/ArchiveExport");

To see the ArchiveExport attributes

Cheers, Bertrand.

Hi

First one gives me:

[code]USAGE: ArchiveExport [Options] {channel}

Options:
-verbose Verbose mode[/code]
So it complains it needs options.

Second on leads to:

Der Befehl "ArchiveExport" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

Strange,
delos

Weird, it works for me with root.exe:

root [0] system(“plink bellenot@bbcc7x64 ls -l /build/bellenot/bin/root/master/bin/root.exe”);
-rwxr-xr-x. 1 bellenot sf 66712 Nov 15 09:06 /build/bellenot/bin/root/master/bin/root.exe
root [1]

So I’m afraid I can’t really help here…

Cheers, Bertrand.

Maybe you could try:

system("plink delos@host \"ls -l /usr/local/bin/ArchiveExport\"");

I now tried this:

system("plink delos@host \"/usr/local/bin/ArchiveExport -o test.dat -start \"12/10/2016 00:00:00\" -end \"19/10/2016 00:00:00\" /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2  \"");

Now it complains it cannot open the file ‘00:00:00’.

I’ll try… I guess it’s all these quotation marks needed.

Cheers,
delos

system("plink delos@host \"/usr/local/bin/ArchiveExport -o test.dat -start \\\"12/10/2016 00:00:00\\\" -end \\\"19/10/2016 00:00:00\\\" /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2  \"");

Hi

This

system("plink acsop@hipalc \"/usr/local/bin/ArchiveExport -o test.dat -start '10/10/2016 00:00:00' -end '10/17/2016 00:00:00' /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2  \"");

works from the root [0] command prompt.
In a macro I again get “the command ArchiveExport cannot be found”.
Weird.
So it is try and error with quotation marks…

Cheers,
delos

Does this work from the macro?

system("plink acsop@hipalc \\\"/usr/local/bin/ArchiveExport -o test.dat -start '10/10/2016 00:00:00' -end '10/17/2016 00:00:00' /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2  \\\"");

No, same error: command ArchiveExport cannot be found.

Last try:

gROOT->ProcessLine("system(\"plink acsop@hipalc \\\"/usr/local/bin/ArchiveExport -o test.dat -start '10/10/2016 00:00:00' -end '10/17/2016 00:00:00' /gfa/archiver-data/archive_ZHE_MT/index MHC1:IST:2  \\\"\");");

Sorry, still doesn’t work. I don’t understand why there is a difference between executing plink from the root [0] command line and executing the same in a macro.
I guess I will create a script with the required information, copy it to the remote host and execute it there.
Thanks to all of you for your persistent help!

Cheers,
delos