bash - Unable to escape $0 in awk script within 2 ssh sessions. Works in 1 ssh session -


i having trouble getting script run.

the following script works (awk within ssh session):

ssh root@db01 "cat /tmp/$togo  \ |openssl aes-256-cbc -d -salt -pass pass:aaaaaaaaaaaaa \ |gunzip \ |gawk -v envbucket='design.test.bucket' -v prodbucket='design.bucket' '{gsub(prodbucket,envbucket);print \$0}' \ |gawk -v envbucket='data.test.bucket' -v prodbucket='data.bucket' '{gsub(prodbucket,envbucket);print \$0}' \ | mysql -u root -p'secret' appdb" 

but when try run exact same thing inside ssh session within ssh session, fails:

ssh root@intermediateserver "ssh root@db02 \"cat /tmp/$togo  \ |openssl aes-256-cbc -d -salt -pass pass:aaaaaaaaaaaaa \ |gunzip \ |gawk -v envbucket='design.test.bucket' -v prodbucket='design.bucket' '{gsub(prodbucket,envbucket);print \$0}' \ |gawk -v envbucket='data.test.bucket' -v prodbucket='data.bucket' '{gsub(prodbucket,envbucket);print \$0}' \ | mysql -u root -p'secret' appdb\"" 

this script works if remove 2 gawk commands , pipe gunzip output directly mysql. gawk commands in pipeline, output becomes empty.

i assume has print $0 not escaping within double-quotes within double-quotes.

i've been stuck on while i'm hoping here can help.

p.s. aware of security risks associated these script. in current form, being run in test environment.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -