0

I'm working on something at the moment and just now I even wonder if what I am working on is even possible.

I want to SSH from jenkins to a shell script and use variables form a rc file that are in a git Repository. (The Shell script and rc file are in the same repo)

Nothing that I tried works and now I'm starting to wondering if it's even possible.

Here's is my local script but i get the same output on jenkins.

docker exec -it test-container bash 'sed -f <(printf "s/${DOMAIN}\.%s/www.&.${DOMAIN_SUFFIX_STAGE}/g\n" ${LANG_KEYS}) /var/www/foo/sed/test.txt > /var/www/foo/sed/new-2.txt'

No matter what I do I get this error

bash: sed -f <(printf "s/${DOMAIN}\.%s/www.&.${DOMAIN_SUFFIX_STAGE}/g\n" ${LANG_KEYS}) /var/www/foo/sed/test.txt > /var/www/foo/sed/new-2.txt: No such file or directory

And yes I can confirm that the directory is there

Spectric
  • 30,714
  • 6
  • 20
  • 43
MewTwo
  • 465
  • 4
  • 14
  • Please do not vandalize posts on Stack Overflow. Although you asked the question, it now counts as a part of an encyclopedia. – Spectric Feb 02 '21 at 22:06

1 Answers1

1

Here's an easier way to reproduce your problem:

$ bash "echo Hello"
bash: echo Hello: No such file or directory

This happens because the expected syntax is bash yourfile. The string you are passing is not a useful filename, so it fails.

To run a string argument as a command, you can use bash -c commandstring:

$ bash -c "echo Hello"
Hello

This makes bash interpret the parameter as a shell command to execute, instead of a filename to open.

that other guy
  • 116,971
  • 11
  • 170
  • 194
  • So does this also work with ssh ? If i replace my docker command with ssh since that's how i log on into the server. – MewTwo Feb 02 '21 at 06:11
  • So the -c did let me run the command with bash. But I don't get the same output as I would if I where to run it without. None of the Parameters from the variables (rc file) are beging accounted for. – MewTwo Feb 02 '21 at 06:40