You are not logged in.
Hello,
I have this script:
#!/bin/sh
SP_CONFIG=/home/flindner/spider/spFackrellB2+innerBox.conf
ssh flindner@yoko "ssh yuka << 'ENDSSH'
MESH=`awk '/OUTFILENAME/ {getline; print}' $SP_CONFIG`
ENDSSH"executed with sh -x
florian@horus ~ % sh -x ./remote_spider_test.sh
+ SP_CONFIG=/home/flindner/spider/spFackrellB2+innerBox.conf
++ awk '/OUTFILENAME/ {getline; print}' /home/flindner/spider/spFackrellB2+innerBox.conf
awk: fatal: cannot open file `/home/flindner/spider/spFackrellB2+innerBox.conf' for reading (No such file or directory)
+ ssh flindner@yoko 'ssh yuka << '\''ENDSSH'\''
MESH=
ENDSSH'But when I execute the awk command on the machine yuka it works just fine:
flindner@yuka:~> awk '/OUTFILENAME/ {getline; print}' /home/flindner/spider/spFackrellB2+innerBox.conf
meshFackrellB2+innerBox.mshTherefore I think that somehow awk is being executed on my local machine and not on either one on the remote machines (I would be running on yoko too).
Why is that? How can I execute it on yoko like it was intented? Other commands played just well, I suspect the problem is connected to the subshell execution of awk.
Thanks a lot!
Offline
The problem here is that the shell will evaluate the string inside "" before running the command. that means the awk-line will run locally. Try using ' instead of " around the ssh yuka ... ENDSSH. Single quotes will prevent the shell from evaluating anything inside like variables or subshell stuff. Also use $( .. ) instead of ` `, because its more readable ![]()
Last edited by seiichiro0185 (2011-09-19 14:11:15)
My System: Dell XPS 13 | i7-7560U | 16GB RAM | 512GB SSD | FHD Screen | Arch Linux
My Workstation/Server: Supermicro X11SSZ-F | Xeon E3-1245 v6 | 64GB RAM | 1TB SSD Raid 1 + 6TB HDD ZFS Raid Z1 | Proxmox VE
My Stuff at Github: github
My Homepage: Seiichiros HP
Offline