如何在执行脚本时切换用户 [英] How to switch user while executing the script

查看:587
本文介绍了如何在执行脚本时切换用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


在我的脚本中,我需要切换到另一个用户来执行一个我没有权限运行的命令。实际上,该脚本将文件从一个目录复制到另一个目录。运行用户的脚本在目标目录中没有权限。所以我需要切换到另一个用户。我在unix中尝试了''su''命令。但是它无法接受密码。我在回复密码时会再次提示输入密码。有没有办法实现这个功能?....请帮助


提前致谢,


Vipin C

Hi guys,

In my script, I need to switch to another user to execute a command which I don''t have the privilege to run. Actually the script copies a file from one directory to another. The script running user doesn''t have the permission in target directory. So I need to switch to another user for the same. I tried ''su'' command in unix.But it failed to accept the password.evenif I echo the password its prompting again for the password when it executes. Is there any way to achieve this functionality?.... Please help

Thanks in advance,

Vipin C

推荐答案

不幸的是,在Perl脚本中无法做到这一点。我知道,虽然很久以前当我正在制作一个需要做两个不同用户的脚本时,我就有这个。唯一的方法是为每个用户创建一个脚本,以启动他们所需的任务。


问候,


杰夫
Unfortunately, there is no way to do this in a Perl script. I know, I had this though quite a while ago when I was working on a script that needed to do stuff as two different users. The only way to do it is to create a script for each user to kick off, to do the tasks they need to.

Regards,

Jeff


谢谢杰夫...

但问题是,Iam从我的一个信息工作流程中调用脚本。当informatica执行脚本时,它作为一个我们无法改变的特定用户执行。这就是为什么我们想到了脚本方法中的切换用户....你能否对这个问题有所了解..


提前谢谢


Vipin C
Thanks Jeff...

But the issue here is, Iam calling the script from one of my informatica workflows. When informatica executes the script it executes as a particular user which we can''t change. That why we thought of switch user in the script method....Can you put some light on this issue..

Thanks in advance

Vipin C


不幸的是,我对Informatica或其工作流程一无所知,所以我甚至无法对此发表评论。我所知道的是,如果您需要脚本完成某些任务,那么这些任务将由启动脚本的用户帐户完成。我不确定你将如何解决你的问题,特别是在自动化的方式,因为它看起来像你正在尝试这样做。


问候,


Jeff
Unfortunately, I know nothing about Informatica or its workflows, so I cannot even begin to comment on that. What I do know is that if you need some tasks done by a script, those tasks will be completed by the user account that kicks off the script. I am not sure how you are going to solve your problem, especially in an automated fashion as it looks like you are trying to do it.

Regards,

Jeff


这篇关于如何在执行脚本时切换用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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