0

I have a user called foo which is using tcsh by default in /etc/passwd. I cannot change that default shell. Foo has a service called xyz running, for which all the startup scripts and .(dot) file containing ENV variables are in home dir of foo.

Now a startup script is also created to run that service and placed in /etc/init.d/xyz which is written in bash.

Now the issue is that the service is not starting on boot and I cannot run it from my default user on login too. It is only possible to run when I su into foo user and execute the script to start the service.

If I do like this

sudo su foo /home/foo/xyz it will show me errors like then: then/endif not found..

So what I want to run a tcsh program to run on boot from a init.d script which is in bash. At present I tried to do this

su - foo -c "source /home/foo/.env_vars && /home/foo/bin/xyz start" but this is not starting the service at the time of boot.

I am not sure how to make a tcsh script execute on boot time.

  • Have you tried sudo -u foo tcsh /home/foo/script ? – jonathanjo Mar 22 '18 at 11:08
  • Pretty much what @jonathanjo says, just use tcsh on the scripts. – towo Mar 22 '18 at 12:27
1

You can either:

  • use tcsh -c $script to run the scripts with tcsh
  • set the shebang (first line) in the script to #!/bin/tcsh and set it executable; you can then just start it with $script as the command.
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.