-1

how to find a shell script is re-executable and would not overwrite the configuration/any such changes made.

Something like bash -x script.sh is used to to debug a script, to check whether each line of the script is getting successfully executed or not.

What i meant is suppose script.sh is having commands to:

  1. Create soft-link for some file
  2. Changing some values to some configuration file.

So, such a script if I execute again and again, would the changes take into effect or it would overwrite and change system's configuration, how do we ensure such things ?

closed as unclear what you're asking by ilkkachu, Jeff Schaller, glenn jackman, slm Jun 19 '18 at 4:58

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    "re-executable" meaning what, exactly? are you perhaps confusing bash -x with test -x? – steeldriver Jun 18 '18 at 14:43
  • [ -x filename] is probably what you are after – LinuxSecurityFreak Jun 18 '18 at 15:01
  • Are you referring to the ability to, if the script exits early with errors, start executing from where the last run left off? – glenn jackman Jun 18 '18 at 15:09
  • What i meant is suppose script.sh is having commands to create softlink for some file and then changing some values to some configuration file. So, such a script if i execute again would the changes take into effect or just come out, how do we ensure such things ? – prat Jun 19 '18 at 4:54
  • You need to take care of this when scripting and make use of testing. There is no way to ensure something like that in an easy way from outside. Please ask a specific question when you have a specific problem. – pLumo Jun 19 '18 at 9:13
1

There's no such thing as reexecutability, as long as the script doesn't remove itself or change its executable permission bit. As that's what executability is about. It's the x you see in the first column while running ls -l. If it's set, the file can be executed (by owner/group/user). If it's not, then it can't. You can always try to execute anything with an interpreter like

bash some_file

But for this the file doesn't have to be executable.

The executable bit is what allows you to call (execute) a script by:

./script.bash

(or whatever it's called).

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