执行sudo -u sbsh之后的用户名

时间:2017-02-09 16:31:52

标签: perl unix sudo

我使用的系统是" user1"我和sudo一样,不同的用户说" sudo -u user2 sbsh"并执行perl脚本。

有没有办法让#34; user1"在我正在运行的脚本中?

我使用了ENV {' USER'}。但它给了" user2"。 ' SUDO_USER'也没有用。

1 个答案:

答案 0 :(得分:0)

尝试SELECT a.No_ ,Sum(b.Consumption) as Consumption ,sum(c.[Item Ledger Entry Quantity]) as 'Total Qty' ,sum(e.Amount) as 'Total Amount' FROM Crest$Item a INNER JOIN (SELECT [Item No_] INo, Sum(Quantity) Consumption FROM [Crest$Item Ledger Entry] WHERE [Entry Type] = 5 and [Posting Date] Between '2017-01-01' and '2017-01-31' GROUP BY [Item No_]) b on a.No_ = b.INo INNER JOIN [Crest$Value Entry] c ON a.No_ = c.[Item No_] INNER JOIN [Crest$G_L - Item Ledger Relation] d on c.[Entry No_] = d.[Value Entry No_] INNER JOIN [Crest$G_L Entry] e ON d.[G_L Entry No_] = e.[Entry No_] WHERE e.[G_L Account No_] = '55130' and c.[Posting Date] between '2017-01-01' and '2017-01-31' group by a.No_ order by a.No_

示例:

$ENV{'SUDO_USER'}