1

on Systemd I would like to execute following command which works fine on shell manually:

/usr/bin/company_program --init.d `/usr/bin/lua -l company_exec -e 'dofile("/etc/company_profiles"); print(table.concat(company_exec.table_to_companyexec_argv(default), " "))'`

How could I transfer it to ExecStartPre which runs:

/usr/bin/lua -l company_exec -e 'dofile("/etc/company_profiles"); print(table.concat(company_exec.table_to_companyexec_argv(default), " "))'

Then feed the result to ExecStart which runs:

/usr/bin/company_program --init.d `${previous_execstartpre_lua_result}`
4
  • On mobile but I believe export will help in this issue May 29, 2017 at 8:18
  • On mobile but I believe export will help in this issue. Pass the output into a variable then export that. May 29, 2017 at 8:27
  • mind to give an answer when you back to your desktop please? Thanks! May 29, 2017 at 8:30
  • I have tried to create such a systemd service but unfortunately isn't so your best bet will be to write a script with those commands and call it from systemd service May 29, 2017 at 13:33

1 Answer 1

1

Put both lines into a script and run it from a single ExecStart= command.

3
  • put into a script works, may I know why I can't include it without script? May 31, 2017 at 1:33
  • The behavior is documented in man systemd.service in the "Command Lines" section. As it says there "... This syntax is intended to be very similar to shell syntax, but only the meta-characters and expansions described in the following paragraphs are understood.... ". It's possible to set an environment variable that is read in by a later bash command. See gist.github.com/nickjacob/9909574 May 31, 2017 at 12:57
  • I see, so there are limitations imposed on ExecStart, Thanks Jun 1, 2017 at 0:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .