[英]Script run in subshell not running same shell as calling script
我有shell A使用nohup調用shell B.
殼A:
echo "\r\n OS1 : $BASH \r\n"
echo "\r\n OS2 : $SHELL \r\n"
$scriptB="B.sh"
(
nohup sh $scriptB $* >> test.log 2>&1
echo process finalized
exit
)
殼B:
echo "\r\n OS1 : $BASH \r\n"
echo "\r\n OS2 : $SHELL \r\n"
在shell AI中得到回聲結果:
OS1 : /usr/bin/bash
OS2 : /usr/bin/sh
在shell BI中獲取echo結果:
OS1 :
OS2 : /usr/bin/sh
為什么bash在通話中被清空了? 如何在下標中繼續使用bash?
這導致我在bash中可用的某些命令中出現語法錯誤,但不是sh
嘗試這個:
檔案A.sh
echo "\r\n OS1 : $BASH \r\n"
echo "\r\n OS2 : $SHELL \r\n"
(
nohup sh ./B.sh $* >> test.log 2>&1
echo process finalized
exit
)
並保持文件B不變,它為兩者打印出相同的輸出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.