在Linux中以其他用户选项运行 [英] Run as Other user Option in Linux

查看:81
本文介绍了在Linux中以其他用户选项运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

案例:

Case :

我的案子很简单.我有一台Linux服务器计算机.在该服务器上,有2个用户.一个是 root ,另一个是 oracle .现在这件事了,root用户不知道 sqlldr 命令,该命令被 oracle 识别仅限用户.

My case is pretty straight forward. I have a Linux server machine. On that server, there are 2 users. One is root and the other is oracle. Now here is the thing, the root user does not know the sqlldr command, this command is recognized by oracle user only.

我有一个 batch.sh 文件,在该文件中,我有一个 sqlldr 命令,该命令将插入记录在数据库中.当我使用 oracle 用户打开终端时,该 batch.sh 文件会根据预期运行.但是,当我使用 root 用户从终端运行该批处理文件时,它说" ./batch.sh:第3行:sqlldr:命令不是找到 ".

I have a batch.sh file and in that file i have an sqlldr command that will insert record in the database. When i open terminal using oracle user, that batch.sh file runs according to the expectations. But when I run that batch file from terminal using the root user, it says "./batch.sh: line 3: sqlldr: command not found".

问题:

Problem:

现在的问题是,我正在从Java代码中调用此batch.sh文件,并且此Java进程以 root 开始.我没有办法将此Java进程切换为oracle.但是,我期望的是,在使用 root 用户.

Now the problem is, I am calling this batch.sh file from java code, and this java process is started as root. There is no way for me to switch this java process to oracle. However what I am expecting is, that i may switch user before executing the command in the batch.sh file using the root user.

这是我的batch.sh文件内容.

Here is my batch.sh file content.

#!/bin/bash

sqlldr username/password@sid control='/path/toFile/control.txt' log='/path/toFile/Results.log' bad='/path/toFile/BadFile.bad' ERRORS=5000

exit 0

我期望这样的事情.

#!/bin/bash

### Start - Switch user here from root to oracle so that it recognize the following command

sqlldr username/password@sid control='/path/toFile/control.txt' log='/path/toFile/Results.log' bad='/path/toFile/BadFile.bad' ERRORS=5000

### End - Undo the switch that we made above

exit 0

任何帮助将不胜感激.

谢谢

推荐答案

您还可以使用

这篇关于在Linux中以其他用户选项运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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