Linux .sh script execution error

First, the problem background

  Today in learning hadopp framework, to write a script sheel hadoop start the process, not wanting to use Linux comes with VM editor in content editing scripts under Windows, and then run this script under Linux, and then they reported several error

  Original error:

Could not find or load main class namenode

Could not find or load main class datanode

  Roughly mean, he could not find me a few nodes.

  At first, I thought it was my hadoop configuration file written a problem, but after some checking, and after Baidu, did not solve my problem, run the script still be wrong. I think this should not my configuration problem, but a problem with this script.

  In order to verify my guess, I would script command, run directly under Linux system, the results of all open hadoop process, not a failure, which proved my guess is correct.

Second, the cause of the problem

  Now, hadoop configuration file is no problem, and that is a problem with the .sh script, and then into too much effort, informed that the file in Windows edit, he is at the end of each line "\ n \ r", and but in the Linux system it is "\ the n-" , that's the problem.

Third, to solve the problem

  Using the command " Sed -i 'S / \ R & lt // $' xxxxxxx.sh ", the .sh file "\ r" replace all whitespace, you can solve the problem

  Finally, experimental testing, run the script file, hadoop process fully open, there is no error, verify through.

Guess you like

Origin www.cnblogs.com/cmxbky1314/p/12096611.html