I have a simple shell script below :
#!/bin/bash
# Hadoop Clear
readOnly hadoop = /opt/hadoop/bin/hadoop
hadoop fs -rm -r /
When I run the script in the terminal of the same machine, everything works without error. Now, I want to invoke this script remotely. So from my java
program, I do an ssh
to the server, and invoke the script as : sh <full Path to script>
.
I get an error saying:
clearHadoop.sh: readOnly: not found
clearHadoop.sh: hadoop not found
Any idea why this happens?
readonly
is a bash keyword, not readOnly
.
This sounds like you are adding the path to hadoop
to $PATH
in a shell init file that only affects interactive sessions (and so not remote sessions).
Also sh
is not /bin/bash
. If you want bash
use bash
and not sh
.
There's a typo in your readOnly line. At least the bash's that I just tried al complained about read O nly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.