在Linux中获取当前命令

时间:2015-08-28 04:46:47

标签: linux shell

我正在创建一个shell脚本,它始终会从shell中读取用户的当前命令。

我目前正在使用我不满意的class ViewController: UIViewController, ADBannerViewDelegate { @IBAction func resetButton() { tapsCount = 0 countdownNumber = 10 colon.text = ":" Timer.valid secondsLeft.text = "10" tapsCounter.text = "0" endMessage.text = "" Timer.invalidate() puppy.frame = CGRectMake( 187, 325, puppy.frame.size.width, puppy.frame.size.height ); } } 命令,因为它用于提示问题。例如:

read

我想在用户直接在命令行上输入命令时调用我的脚本(登录后脚本已经通过/etc/profile.d/myapp.sh运行了。)

root@hostname: ./script.sh
Question here?
answer - `read` command 

我的示例脚本root@hostname: read the command here result will happen

myapp.sh

1 个答案:

答案 0 :(得分:0)

如果您明确定位Bash,我建议为这些命令设置Bash别名。

在用户会话开始时,您的程序可以运行以下命令来创建bash别名:

alias command1="/your/path/script.sh command1"
alias command2="/your/path/script.sh command2"

然后,例如,当用户输入command1时,它将展开并改为运行/your/path/script.sh command1

相关问题