Re: Cannot rum multiple command on remote machine via SSH
- To: debian-user@lists.debian.org
- Subject: Re: Cannot rum multiple command on remote machine via SSH
- From: Kamil Jońca <kjonca@o2.pl>
- Date: Sat, 04 Feb 2023 13:26:07 +0100
- Message-id: <[🔎] 87bkm9mxb4.fsf@alfa.kjonca>
- In-reply-to: <FVoU1-3mS4-3@gated-at.bofh.it> (Ottavio Caruso's message of "Sat, 04 Feb 2023 12:30:01 +0100")
- References: <FVoU1-3mS4-3@gated-at.bofh.it>
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
> Hi,
>
> LAP1 is a Thinkpad that I use only at home as a poor man's desktop.
>
> LAP2 is a second Thinkpad that I use mainly outdoors, on which I run
> an SSH server to do some syncing every now and again.
>
> Both using latest Debian stable with similar sets of apps.
>
> At night, I want to connect to LAP2 and perform these commands:
>
> $ sudo tlp setcharge 90 95 BAT1 # resets battery settings for external
> battery
>
> $ hibernate.sh # a script that performs some housekeeping, puts laptop
> into hibernation and eventually disconnects sshd.
>
> From LAP1 I can issue:
>
> $ ssh LAP2 sudo tlp setcharge 90 95 BAT1 # it works
>
> or:
>
> $ ssh LAP2 hibernate.sh # it works too
>
> but either:
>
> $ ssh LAP2 "sudo tlp setcharge 90 95 BAT1 && hibernate.sh"
>
> or
>
> $ ssh LAP2 "sudo tlp setcharge 90 95 BAT1 ; hibernate.sh"
>
> return:
>
> hibernate.sh: command not found
your shell interpret this as two commands
1. run "sudo tlp setcharge 90 95 BAT1"
2. then run "hibernate.sh" (without sudo)
you can try
--8<---------------cut here---------------start------------->8---
ssh LAP2 "sudo tlp setcharge 90 95 BAT1 ; sudo hibernate.sh"
--8<---------------cut here---------------end--------------->8---
or
--8<---------------cut here---------------start------------->8---
ssh LAP2 "sudo sh -c 'tlp setcharge 90 95 BAT1 ; hibernate.sh'"
--8<---------------cut here---------------end--------------->8---
>
>
> Why?
KJ
--
http://wolnelektury.pl/wesprzyj/teraz/
Reply to: