下面是我的脚本,我需要在该脚本中传递密码作为参数
#!/usr/bin/expect -f
set password [lindex $argv 0];
spawn iroot
expect ".* password for"
sleep 3
send "$password\r"
sleep 5
send "dmidecode -t system | grep Manufacturer > /tmp/manufacdetails.txt\r"
send "exit\r"
interact
我试图像下面这样执行
./getmanufacdetailsTest.sh password123
但是它似乎没有用。你能告诉我我在做什么错吗
答案 0 :(得分:2)
prog.sh:
#!/bin/bash
input=$1
echo "the arg passed to my prog is $1"
在控制台中:
./prog.sh one1
输出:one1