linux 火狐无法执行二进制文件_“无法执行二进制文件”尝试在Linux上运行Shell脚本时...

I am very new to linux and shell scriprting.

I am trying to run a shellscript from secure shell (ssh) on linux using following commands:

chmod +x path/to/mynewshell.sh

sh path/to/mynewshell.sh

I get this error:

path/to/mynewshell.sh: path/to/mynewshell.sh: cannot execute binary file.

Tried using this command:

bash path/to/mynewshell.sh

I get the same error.

Tried with this command: su - myusername sh path/to/mynewshell.sh

It is asking for my password and giving me this error: no such file or directory.

1.The result of cat -v path/to/mynewshell.sh is:

^@^@^@^@^@^@^@^@Rscript "$dir"/diver_script.R

done

2.When tried 'less path/to/mynewshell.sh' i got this on my terminal:

#!/bin/bash/Rscript^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

for dir in /path/to/* ; do

^@^@^@^@^@^@^@^@Rscript "$dir"/myRscript.R

done

3.When i ran file path/to/mynewshell.sh : i got this "Bourne-Again shell script text executable"

Please give any advice on how I can try executing the shellscript.

解决方案

chmod -x removes execution permission from a file. Do this:

chmod +x path/to/mynewshell.sh

And run it with

/path/to/mynewshell.sh

As the error report says, you script is not actually a script, it's a binary file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值