使用带有别名的nohup [英] Using aliases with nohup

查看:1479
本文介绍了使用带有别名的nohup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么没有了以下工作?

Why doesn't the following work?

$ alias sayHello='/bin/echo "Hello world!"'
$ sayHello 
    Hello world!
$ nohup sayHello
    nohup: appending output to `nohup.out'
    nohup: cannot run command `sayHello': No such file or directory

(我问这个问题的原因是因为我已经我的别名 perl的蟒蛇不同的Perl /这是为我自己的目的进行了优化蟒蛇二进制文件;但是,nohup的给我的麻烦,如果我不提供完整路径,我的Perl / Python的二进制文件)

(the reason I ask this question is because I've aliased my perl and python to different perl/python binaries which were optimized for my own purposes; however, nohup gives me troubles if I don't supply full path to my perl/python binaries)

推荐答案

由于shell不给子进程传递别名(除非您使用$()或``)。

Because the shell doesn't pass aliases on to child processes (except when you use $() or ``).

$别名的sayHello ='/斌/回声世界,你好!

$ alias sayHello='/bin/echo "Hello world!"'

现在的别名是在这个shell进程,这是很好的知道,但只有在这一个shell进程的工作。

Now an alias is known in this shell process, which is fine but only works in this one shell process.

$ sayHello 

Hello world!

既然你说的sayHello,在它的工作相同的外壳。

Since you said "sayHello" in the same shell it worked.

$ nohup sayHello

下面,一个程序的nohup正在启动一个子进程。因此,将不会收到别名。
然后,它启动子进程的sayHello - 这是没有找到

Here, a program "nohup" is being started as a child process. Therefore, it will not receive the aliases. Then it starts the child process "sayHello" - which isn't found.

有关您的特定问题,最好使新的Perl和巨蟒看起来像普通的人尽可能多地。我建议设置的搜索路径。

For your specific problem, it's best to make the new "perl" and "python" look like the normal ones as much as possible. I'd suggest to set the search path.

在你的〜/ .bash_profile中加入:
出口PATH =/我/有光泽/间preters /斌:$ {PATH}

In your ~/.bash_profile add: export PATH="/my/shiny/interpreters/bin:${PATH}"

然后重新登录。

由于这是一个环境变量,它的将会的传递给所有的子进程,无论是弹还是不 - 它现在应该很经常工作

Since this is an environment variable, it will be passed to all the child processes, be they shells or not - it should now work very often.

这篇关于使用带有别名的nohup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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