Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my company, there are a lot of maintain scripts. I found one start like with:

# the next line restarts using expectk \
exec `ksh -c "echo /usr/bin/expectk \"$0\" -- $*"`

But I don't understand why and how it restarts using expectk.

Anyone help?

share|improve this question

That command looks way more complicated than it needs to be. Essentially what its doing (and could be shortened down to) is

exec /usr/bin/expectk $0 -- $*

Your script is execing the output of the echo command. The rewritten version above removes the echo and just does the exec directly. However the better way to do it is

exec /usr/bin/expectk "$0" -- "$@"

This fixes issues that would pop up if any of the arguments to the script contained spaces.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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