1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

特定のコマンドだけ別ユーザで実行する

Posted at

目的

特定のコマンドだけ別ユーザで実行する。
プロジェクトで規定されてる、シェルの実行ユーザだとoracle周りのコマンドを叩く権限がないので何とかしたい。

# シェルの実行ユーザで実行される
touch start.txt

# ここだけoracleユーザで実行する
su - oracle -c sqlplus ***/***@*** @***.sql

# シェルの実行ユーザで実行される
touch end.txt

所感

-c オプションってこういう風に使うのか。
man su見ても、この説明からこんな挙動をするとは思えないよねぇ。

-c command, --command=command
対話的なシェルを起動するのではなく、シェルに -c オプションとともに command (実行されるコマンドライン一行) を渡す。

ところで、qiitaのタグで「shell」と「ShellScript」と「shellスクリプト」でタグ分かれてるの何とかならんのかしら。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?