I want to pass a variable in ssh. Remote OS is not Unix/Linux.It is Ericsson SmartEdge OS.

Content of newentry.txt seq 10 deny ip host any

My syntax is

ENTRY=`head -1 /scripts/newentry.txt`
ssh user@ "configure; context NS; ip access-list NS_OUT; $ENTRY;"

When I run the script it's shows following`

ENTRY=head -1 $NEWENTRY_PATH ++ head -1 /scripts/zabbix/newentry.txt + ENTRY='seq 50 deny ip host any'

ssh user@ "context NS; show ip access-list NS_OUT" | tail -2 | head -1 | awk '{$1=$1}1' > $ACL_PATH + ssh user@ 'context NS; show ip access-list NS_OUT' + tail -2 + head -1 + awk '{$1=$1}1' user@'s password:

awk '{ print "seq '$NEWSEQUENCENUMBER' deny ip host '$NEWIPSOURCEADDRESS' any" }' $ACL_PATH > $NEWENTRY_PATH + awk '{ print "seq 50 deny ip host any" }' /scripts/zabbix/acl.txt sed '1d' $ATTACKERS_PATH > /dev/null + sed 1d /scripts/zabbix/attackers.txt

ssh user@ 'configure; context NS; ip access-list NS_OUT; echo $ENTRY;"' + ssh user@ 'configure; context NS; ip access-list NS_OUT; echo $ENTRY;"' user@'s password: Unmatched ". printf "%s\n" "$ENTRY" + printf '%s\n' 'seq 50 deny ip host any' seq 50 deny ip host any

closed as unclear what you're asking by mdpc, Jakuje, G-Man, jasonwryan, xhienne Jan 17 '17 at 0:35

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    OK, so what is the remote system type/distribution? – mdpc Jan 16 '17 at 21:49
  • 1
    (1) Is the ENTRY variable being set correctly?  If you say printf "%s\n" "$ENTRY", does it display what you expect?  (2) Can you give us a hint what the value of $ENTRY is?  Is it a command?  (3) What happens when you run your commands?  … … … … … … … … … … … … … … … … … … … …  Please do not respond in comments; edit your question to make it clearer and more complete. – G-Man Jan 16 '17 at 23:14
  • The output that you posted doesn't seem to correspond to the script that you posted. – G-Man Jan 21 '17 at 5:50

If you use

ssh pvt@ "~/tools/run_pvt.pl $BUILD_NUMBER"

instead of

ssh pvt@ '~/tools/run_pvt.pl $BUILD_NUMBER'

your shell will interpolate the $BUILD_NUMBER before sending the command string to the remote host.

  • mdpc it is Ericsson SmartEdge OS – David Jan 17 '17 at 11:36
  • dbkonXepts You mean that I must run the script in ssh string? – David Jan 17 '17 at 12:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.