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

#!/bin/sh
# 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?

link|improve this question

0% accept rate
feedback

1 Answer

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

#!/bin/sh
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

#!/bin/sh
exec /usr/bin/expectk "$0" -- "$@"

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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