ssh - How to make awk works in perl? -
in perl scripts, code:
system("ssh -q ullink\@130.45.56.217 \"echo 1 2|awk '{print \$2}'\""); the awk part doesn't work! expect result "1", it's "1 2" can't figure out how make work?
why run awk on remote host, or @ all?
system(qq(ssh -q $ul_server_login\@$ul_server echo 1 2 | awk '{print $2}')); or better
print ((split (/\s+/,qx(ssh -q $ul_server_login\@$ul_server echo 1 2)))[1]); the concrete problem script dollar sign requires lot more escapes: gets eaten remote shell; if escape remote shell backslash, backslash needs escaped perl, etc etc. it's lot simpler if use single quotes can.
system("ssh -q $ul_server_login\@$ul_server " . '"echo 1 2 | awk \'{ print \$2 }\'"');
Comments
Post a Comment