bash: ./a.sh: /bin/bash^M: bad interpreter: No such file or directory的解决方法

一些人喜欢用vim来写linux shell script, 但是, 有的人喜欢在Windows下用一些方便的编辑器(比如鼎鼎大名的Notepad++)写好, 然后拷贝文件到linux下, 结果呢, 在执行脚本a.sh的时候, 会出现如下问题:

[plain] view plain copy
  1. [taoge@localhost learn_shell]$ ./a.sh   
  2. bash: ./a.sh: /bin/bash^M: bad interpreter: No such file or directory  
  3. [taoge@localhost learn_shell]$   

      什么原因呢, 我们有理由怀疑是文件格式问题? 我们用vim a.sh进入a.sh这个文件, 然后在底部模式下, 执行:set ff查看一下, 结果发现fileformat=dos, 看看, 果然是文件格式问题, 那怎么解决呢?


     方法一:vim a.sh进入a.sh后, 在底部模式下, 执行:set fileformat=unix后执行:x或者:wq保存修改。 然后就可以执行./a.sh运行脚本了。(我亲自试过, 是ok的)

     方法二:直接执行sed -i "s/\r//" a.sh来转化, 然后就可以执行./a.sh运行脚本了。(我亲自试过, 是ok的)

     方法三:直接执行dos2unix a.sh来转化, 然后就可以执行./a.sh运行脚本了。(我的linux上执行dos2unix ./a.sh失败, 但是不要放弃啊, 加个busybox就可以了), 如下:

[plain] view plain copy
  1. dos2unix a.sh   
  2. bash: dos2unix: command not found  
  3. [taoge@localhost learn_shell]$ busybox dos2unix a.sh   
  4. [taoge@localhost learn_shell]$  


展开阅读全文

HADOOP2.6+SQOOP1.99.4-Oracle导入提示:/bin/bash: /bin/java: No such file or directory

01-11

本人Hadoop新手,本机Mac环境,版本如下:rnHadoop:2.6.0rnSqoop:1.99.4rnrn使用Sqoop从Oracel导入到Hdfs时错误:/bin/bash: /bin/java: No such file or directory;(从web端的Log查看);rn1、web端log如下:rnhttp://6thman-Pro.local:8088/cluster/app/application_1420939266073_0002rnApplication application_1420894910576_0001 failed 2 times due to AM Container for appattempt_1420894910576_0001_000002 exited with exitCode: 127rnFor more detailed output, check application tracking page:http://wqdeMacBook-Pro.local:8088/proxy/application_1420894910576_0001/Then, click on links to logs of each attempt.rnDiagnostics: Exception from container-launch.rnContainer id: container_1420894910576_0001_02_000001rnExit code: 127rnStack trace: ExitCodeException exitCode=127:rnat org.apache.hadoop.util.Shell.runCommand(Shell.java:538)rnat org.apache.hadoop.util.Shell.run(Shell.java:455)rnat org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:715)rnat org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:211)rnat org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:302)rnat org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:82)rnat java.util.concurrent.FutureTask.run(FutureTask.java:266)rnat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)rnat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)rnat java.lang.Thread.run(Thread.java:745)rnContainer exited with a non-zero exit code 127rnFailing this attempt. Failing the application.rnrnrn2、Job信息如下:rn>show job all:rnJob with id 8 and name newTest2 (Enabled: true, Created by wq at 15-1-10 下午8:01, Updated by wq at 15-1-10 下午8:57)rnUsing link id 4 and Connector id 1rn From database configurationrn Schema name: PBEMrn Table name: PRO_RTUrn Table SQL statement: rn Table column names: rn Partition column name: rn Null value allowed for the partition column: rn Boundary query: rn Throttling resourcesrn Extractors: 2rn Loaders: 2rn ToJob configurationrn Output format: TEXT_FILErn Compression format: NONErn Custom compression format: rn Output directory: /user/wq/sqoop/rnrn3、从sqoop.log看,远程数据库已经成功获取表及字段信息,但本地未成功;怀疑/user/wq/sqoop的路径不对,但本机使用:hdfs dfs -ls 可成功查看该路径;rnrnsqoop.log如下:rn2015-01-11 09:26:47,732 INFO jdbc.GenericJdbcFromInitializer [org.apache.sqoop.connector.jdbc.GenericJdbcFromInitializer.configureTableProperties(GenericJdbcFromInitializer.java:320)] Field names: ORGNO,ID,STATUS,NAME,GUID,SORTBY,PROPERTY,ISPHYSICALDEVICES,COMPANYID,SUBSTATIONID,CHARGEACCOUNT,CTRLHOSTID,ADDRESS,CHANNELMODE1,CHANNELID1,CHANNELMODE2,CHANNELID2,CHANNELMODE3,CHANNELID3,IPPORT1,IPPORT2,TEL1,TEL2,ASSETNUMBER,FACTORY,MODEL,SETUPDATETIME,SETUPPOSITION,SETUPOPERATOR,SCHEMEID,PASSWORD,AREACODEID,AUTOGETEVENT,HEARTOUTTIME,EVENTID1,EVENTID2,WAKEMODE,CONTROLFLAG,MASTERID,SIMCARDNUMBER,CONTACTMAN,CONTACTADDR,CONTACTPHONE,TRANSFORMERDID,OWNER,LINEID,CONSUMERID,RULEIDrn2015-01-11 09:26:47,918 DEBUG driver.JobManager [org.apache.sqoop.driver.JobManager.createJobRequest(JobManager.java:377)] Using entities: Frominitializer=org.apache.sqoop.connector.jdbc.GenericJdbcFromInitializer, destroyer=org.apache.sqoop.connector.jdbc.GenericJdbcFromDestroyer, partitioner=org.apache.sqoop.connector.jdbc.GenericJdbcPartitioner, extractor=org.apache.sqoop.connector.jdbc.GenericJdbcExtractor, To initializer=org.apache.sqoop.connector.hdfs.HdfsToInitializer, destroyer=org.apache.sqoop.connector.hdfs.HdfsToDestroyer, loader=class org.apache.sqoop.connector.hdfs.HdfsLoaderrn2015-01-11 09:26:47,918 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.begin(JdbcRepositoryTransaction.java:73)] Tx count-begin: 1, rollback: falsern2015-01-11 09:26:47,920 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.commit(JdbcRepositoryTransaction.java:84)] Tx count-commit: 1, rollback: falsern2015-01-11 09:26:47,920 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:103)] Tx count-close: 0, rollback: falsern2015-01-11 09:26:47,920 INFO repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:111)] Attempting transaction commitrn2015-01-11 09:26:49,785 DEBUG mr.SqoopInputFormat [org.apache.sqoop.job.mr.SqoopInputFormat.getSplits(SqoopInputFormat.java:76)] Partition: 10000004 <= ID AND ID < 10000012.5rn2015-01-11 09:26:49,786 DEBUG mr.SqoopInputFormat [org.apache.sqoop.job.mr.SqoopInputFormat.getSplits(SqoopInputFormat.java:76)] Partition: 10000012.5 <= ID AND ID <= 10000021.0rn2015-01-11 09:26:50,304 DEBUG mapreduce.MapreduceSubmissionEngine [org.apache.sqoop.submission.mapreduce.MapreduceSubmissionEngine.submit(MapreduceSubmissionEngine.java:253)] Executed new map-reduce job with id job_1420939266073_0002rn2015-01-11 09:26:50,305 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.begin(JdbcRepositoryTransaction.java:73)] Tx count-begin: 1, rollback: falsern2015-01-11 09:26:50,307 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.commit(JdbcRepositoryTransaction.java:84)] Tx count-commit: 1, rollback: falsern2015-01-11 09:26:50,307 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:103)] Tx count-close: 0, rollback: falsern2015-01-11 09:26:50,307 INFO repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:111)] Attempting transaction commitrn2015-01-11 09:26:55,513 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.begin(JdbcRepositoryTransaction.java:73)] Tx count-begin: 1, rollback: falsern2015-01-11 09:26:55,513 DEBUG derby.DerbyRepositoryHandler [org.apache.sqoop.repository.derby.DerbyRepositoryHandler.findDriver(DerbyRepositoryHandler.java:1073)] Looking up Driver and config rn2015-01-11 09:26:55,515 DEBUG derby.DerbyRepositoryHandler [org.apache.sqoop.repository.derby.DerbyRepositoryHandler.findDriver(DerbyRepositoryHandler.java:1129)] Looked up Driver and configrn2015-01-11 09:26:55,515 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.commit(JdbcRepositoryTransaction.java:84)] Tx count-commit: 1, rollback: falsern2015-01-11 09:26:55,515 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:103)] Tx count-close: 0, rollback: falsern2015-01-11 09:26:55,515 INFO repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:111)] Attempting transaction commitrn2015-01-11 09:26:55,516 INFO default [org.apache.sqoop.audit.FileAuditLogger.logAuditEvent(FileAuditLogger.java:86)] user=wq ip=127.0.0.1 op=status obj=job objId=8rn2015-01-11 09:26:55,516 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.begin(JdbcRepositoryTransaction.java:73)] Tx count-begin: 1, rollback: falsern2015-01-11 09:26:55,517 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.commit(JdbcRepositoryTransaction.java:84)] Tx count-commit: 1, rollback: falsern2015-01-11 09:26:55,517 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:103)] Tx count-close: 0, rollback: falsern2015-01-11 09:26:55,517 INFO repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:111)] Attempting transaction commitrn2015-01-11 09:26:55,598 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.begin(JdbcRepositoryTransaction.java:73)] Tx count-begin: 1, rollback: falsern2015-01-11 09:26:55,599 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.commit(JdbcRepositoryTransaction.java:84)] Tx count-commit: 1, rollback: falsern2015-01-11 09:26:55,599 DEBUG repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:103)] Tx count-close: 0, rollback: falsern2015-01-11 09:26:55,600 INFO repository.JdbcRepositoryTransaction [org.apache.sqoop.repository.JdbcRepositoryTransaction.close(JdbcRepositoryTransaction.java:111)] Attempting transaction commitrn rnrnrn自己只能看出明显的:exitcode:127、还有就是No such file or directory;rn折腾修改了一天,还是没找到原因,还请高手指点,不知道哪里理解、设置的不对;rn新号(之前的不能用了),分不多,请高手仗义出手,感谢!rn 论坛

没有更多推荐了,返回首页