Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
add comment

Your Answer

 
discard

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.