Re: Why are the arguments supplied for the command run through ssh interpreted by shell before they are passed to the command on the server side?

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



On Sat, 11 Jan 2020, Yuri wrote:

> It's not obvious why does it have to be this way. ssh sends the command as an
> array of strings. The first string is the command, and the subsequent strings

It doesn’t.

This works:

  94 ssh root@$hostbase "
  95         PS4='(${hostbase%%.*})++++ '
  96         set -ex
  97         psql -U veraweb -h 127.0.0.1 veraweb
  98         rm -rf /var/lib/tomcat$tomcat/webapps/veraweb
  99         rm -rf /var/lib/tomcat$tomcat/webapps/vwor
 100     " <core/src/main/files/upgrade.sql

Here, $hostbase and $tomcat are expanded locally. Full code:
https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=veraweb/veraweb.git;a=blob;f=upload.sh;h=b8b0cf92ad36dbc929afd86effe44d9bec888344;hb=HEAD

If you wish for no local expansion, quote locally, such as:

ssh -l luser remotehost '
	command1
	command2
	…
'

Quote any ‘'’ inside as “'\''”, that’s it. (Easily done, for
example in AT&T ksh93/GNU bash/mksh: ${cmd//\'/\'\\\'\'})

bye,
//mirabilos
-- 
tarent solutions GmbH
Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/
Tel: +49 228 54881-393 • Fax: +49 228 54881-235
HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev




[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux