Command not found when I call `./myshell` in ruby

不问归期 提交于 2019-12-11 10:28:25

问题


Today, I tried to call a script from ruby. I did like this:

`./aaa.sh`,

but it returned 'command not found', here is the session log of irb:

irb(main):012:0> `which aaa.sh`
=> "/root/rocky/aaa.sh\n"
irb(main):013:0> `aaa.sh`
(irb):13: command not found: aaa.sh
=> ""
irb(main):014:0> `./aaa.sh`
(irb):14: command not found: ./aaa.sh
=> ""

But, if I call it as 'sh aaa.sh', it works.

irb(main):015:0> `sh aaa.sh`
=> "aaa.sh\ntest.rb\n"

so, what's wrong whith this?


回答1:


A couple possibilities immediately come to mind:

  1. Your aaa.sh file doesn't have execute permission.
  2. Your aaa.sh file doesn't start with #!/bin/sh so the OS doesn't know how to execute it.

As an aside, are you really experimenting while logged in as root? That's a quick and easy way to have a really bad day.



来源:https://stackoverflow.com/questions/8074515/command-not-found-when-i-call-myshell-in-ruby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!