calling a ruby script by double-clicking does not

2019-07-10 08:36发布

I've got a ruby script myscript.sh like this

#!/usr/bin/env ruby
puts 'do some ruby stuff'

opening a terminal and calling it with ./myscript.sh just works fine.

But when I try doubleclicking the file it does not.

A simple shell script like this works just fine either by doubleclicking or terminal.

#!/bin/bash  
echo 'TEST' > Test.txt

I am using Ubuntu 11.04

I also use rvm aka Ruby Version Manager. The Problem was that I also require nokogiri. So I needed to set up rvm in my Scriptings to resolve the necessary resources, which I did with a startscript containing

#!/bin/bash

if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then

  \# First try to load from a user install
  source "$HOME/.rvm/scripts/rvm"

elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then

  \# Then try to load from a root install
  source "/usr/local/rvm/scripts/rvm"

else

  printf "ERROR: An RVM installation was not found.\n"

fi


./myscript.sh

1条回答
欢心
2楼-- · 2019-07-10 09:23

My guess is it runs in background, with no window.

Try:

#!/usr/bin/env ruby
File.open('rubytest.txt', 'w') do |f|
  f.puts 'do some ruby stuff'
end

and check if rubytest.txt exists.

查看更多
登录 后发表回答