如何编写启动会议TMUX一个shell脚本,然后运行一个Ruby脚本 [英] How to write a shell script that starts tmux session, and then runs a ruby script

查看:1375
本文介绍了如何编写启动会议TMUX一个shell脚本,然后运行一个Ruby脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个shell脚本,做到这一点:结果
  首先,创建一个会话TMUX结果
  其次,运行名为run.rb里面的TMUX会话的Ruby脚本

在伪code,我想要做的:

  TMUX新的-s my_session
红宝石run.rb#注:我想这对my_session TMUX会话中运行。
TMUX分离

我如何做到这一点? (更多帖子我看了,更混淆它得到。)

谢谢!


解决方案

 #!/斌/庆典
TMUX新的-s my_session
红宝石run.rb
TMUX分离


  1. 创建一个名为 my_script.sh ,并给它上面的内容。


  2. 运行使文件的可执行文件:

    行chmod 755 my_script.sh
    要么
    搭配chmod + X my_script.sh


  3. 然后运行shell脚本:

    ./ my_script.sh


使shell脚本可执行

在执行行chmod 755文件名命令你允许所有人读取和执行该文件,并将该文件所有者可以写入文件中。您可能需要为这个Perl和其他脚本应该通过一个网络服务器上运行。如果你申请755到一个目录,这意味着每个人都可以去,并得到它的文件清单。

这些权限通常被翻译成文本再presentation rwxr-XR-X

您可以选择使用搭配chmod + X FILE_NAME 上的文件,以使其可执行。

更新:

要运行TMUX会话中的Ruby脚本:

 #!/斌/庆典
TMUX新的会话-d -s my_session'红宝石run.rb
TMUX分离-s my_session

I want to write a shell script that does this:
First, create a tmux session
Second, run a ruby script called "run.rb" INSIDE the tmux session

In pseudo-code, what I want to do:

tmux new -s my_session
ruby run.rb     # NOTE: I want this to run inside the my_session tmux session.
tmux detach

How do I do this? (More posts I read, more confusing it gets.)

Thanks!

解决方案

#!/bin/bash
tmux new -s my_session
ruby run.rb
tmux detach

  1. Create a file named my_script.sh and give it the above contents.

  2. Make the file executable by running:

    chmod 755 my_script.sh or chmod +x my_script.sh

  3. Then run the shell script:

    ./my_script.sh

Making the shell script executable

When you perform the chmod 755 filename command you allow everyone to read and execute the file, and the file owner is allowed to write to the file as well. You may need this for Perl and other scripts that should be run via a webserver. If you apply 755 to a directory, it means that everyone can go to it and get its file listing.

These permissions are usually translated into textual representation of rwxr-xr-x.

You can alternatively use chmod +x file_name on a file to make it executable.

Update:

To run the ruby script inside the tmux session:

#!/bin/bash
tmux new-session -d -s my_session 'ruby run.rb'
tmux detach -s my_session

这篇关于如何编写启动会议TMUX一个shell脚本,然后运行一个Ruby脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆