Re: Comparing strings
ELCV <[email protected]> Wed, 14 Jul 2021 10:09:17 -0700 (PDT)
| Newsgroups | alt.comp.lang.shell.unix.bourne-bash |
|---|---|
| Message-ID | <[email protected]> |
> Try changing your ssh command to be: > > ssh [email protected] dd of=/backup/images/${ARG}_0.img > That works! Thank you again. On Wednesday, July 14, 2021 at 11:58:17 AM UTC-4, Grant Taylor wrote: > On 7/14/21 9:42 AM, ELCV wrote: > > A new issue. I am evaluating my script so I am using echo to display > > the commands. > > > > My function is as follows: > > singleVolume(){ > > # OS Volumes > > echo "virsh suspend $ARG" > > echo "dd if=/dev/vg0/$ARG_0 | ssh [email protected] dd of=/backup/images/$ARG_0.img" > > echo "virsh resume $ARG" > > } > > > > When I run my command the $ARG variable in the second line is not echoed: > > > > virsh suspend FOO > > dd if=/dev/vg0/ | ssh [email protected] dd of=/backup/images/.img > > virsh resume LIMS2 > > > > So the variable and the _0 are being dropped. I've tested without > > "echo" and obtained the same result. > > > > If I create a new variable, SUFF="_0" and then use echo > > "dd if=/dev/vg0/$ARG$SUFF | ssh [email protected] dd > > of=/backup/images/$ARG$SUFF.img" > > > > It works. Is this expected? It only seems an issue using functions. > I don't know if I would /expect/ it per se or not. But I am not at all > surprised by it. > > This hints at an escaping problem to me. Maybe. Maybe not. > > Try changing your ssh command to be: > > ssh [email protected] dd of=/backup/images/${ARG}_0.img > > Avoid the abiguity of what is variable vs appended string. > > Aside: That might not be the escaping that I was referring to as > escaping would usually be how your local shell interprets $ARG, or not, > prior to sending it to the remote shell / sub-command. Escaping is more > about where the expansion should happen. And I think your primary / > current issue is what is the variable vs data. > > > Thanks. > > You're welcome. > -- > Grant. . . . > unix || die