期望脚本中的sudo问题 [英] Problems with sudo inside expect script

查看:80
本文介绍了期望脚本中的sudo问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行以下脚本

#!/usr/bin/expect -f

set user [lindex $argv 0]
set pass [lindex $argv 1]
set PATH [lindex $argv 2]
set INV_PATH [lindex $argv 3]

spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@localhost

expect "assword: "
send "$pass\r"
expect "$ "
send "echo $pass | /usr/local/bin/sudo -S $INV_PATH/orainstRoot.sh\r"

expect "$ "
send "cd $PATH/bin\r"

expect "$ "
send "echo $pass | /usr/local/bin/sudo -S cp oraenv coraenv sqlplus dbhome /usr/bin\r"

expect "$ "
send "echo $pass | /usr/local/bin/sudo -S $PATH/root.sh\r"

expect "Check"
send "\r"

在某些计算机上工作正常,并且对于某些计算机,它引发以下错误...我已经检查过,它不是导致问题的PATH.

Its working fine in some machines and for some machines its throwing the following error... I have checked, its not the PATH causing the issue.

/usr/local/bin/sudo: /scratch/prod_sw/app/oraInventory/orainstRoot.sh: command not found
$ echo PASSWD | /usr/local/bin/sudo -S cd /scratch/prod_sw/app/prod_sw/product/11.2.0/db_home/bin
/usr/local/bin/sudo: cd: command not found
$ echo PASSWD | /usr/local/bin/sudo -S cp oraenv coraenv sqlplus dbhome /usr/bin
cp: cannot stat `oraenv': No such file or directory
cp: cannot stat `coraenv': No such file or directory
cp: cannot stat `sqlplus': No such file or directory
cp: cannot stat `dbhome': No such file or directory
$ echo PASSWD | /usr/local/bin/sudo -S /scratch/prod_sw/app/prod_sw/product/11.2.0/db_home//root.sh
Check /scratch/prod_sw/app/prod_sw/product/11.2.0/db_home/install/root_slcad22rhu_2013-07-22_04-41-49.log for the output of root script

推荐答案

尝试提供这些文件的完整路径,然后检查一次.

Try to give complete path for these files and check once.

cp/path/oraenv/path/coraenv/path/sqlplus/path/dbhome/usr/bin

cp /path/oraenv /path/coraenv /path/sqlplus /path/dbhome /usr/bin

这篇关于期望脚本中的sudo问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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