I am writing a shell script where I have to delete a file on a remote machine via a shell script.
Manual workflow:
- Log on to remote machine:
ssh username@domain.example - At the remote machine (
domain), type the following commandscd ./some/where rm some_file.war
How should I accomplish that task in a script?
-ftormexecuting remote call ? – Fedir RYKHTIK May 07 '14 at 15:43rmthey should certainly be passed on to the caller unless the user knows what to expect and why they are overriding something. Lots of mistakes and frustrating debuging later can be avoided by only using the options you need in a given senario. – Caleb May 07 '14 at 20:20-r, but-f) – Fedir RYKHTIK May 09 '14 at 13:53-foption tormis short for--forceand has an effect an whether errors are thown for non-existing files or bogus arguments. Usually commands run over non interactive shells default to being less interactive anyway, but it yous is not or you are getting an interactive prompt the thing to do would be to fix the settings directly related to that. If you are scripting this you shouldn't have that issue anyway, and if you are in an interactive shell (where you have the possibility of catastrophic typos) you should use-Ion--interactive=neverto set your desired behavior. – Caleb May 09 '14 at 14:06ssh user@host echo "\$-"has "i", it's an interactive shell. – Fedir RYKHTIK May 09 '14 at 14:21ssh somesystem 'rm -f somefile'– SDsolar Oct 24 '17 at 01:07