C语言结果为什么出现Expect(Line #1): 192153583832705706 ----------------- Your(Line #1): -89478485
时间: 2024-01-03 10:22:54 浏览: 24
根据提供的引用内容,无法确定具体的代码逻辑和上下文。但是根据错误提示"Expect(Line #1): 192153583832705706"和你的代码"-89478485?",可以推测出可能是因为你的代码逻辑有误导致结果不符合预期。
为了更好地帮助你解决问题,请提供更多的代码和上下文信息,以便我能够更准确地回答你的问题。
相关问题
expect script for ssh-copy-id
Here is an example expect script for automating the `ssh-copy-id` command:
```
#!/usr/bin/expect
set timeout 10
set host [lindex $argv 0]
set password [lindex $argv 1]
set ssh_key [lindex $argv 2]
spawn ssh-copy-id -i $ssh_key $host
expect {
"*(yes/no)?" {
send "yes\r"
exp_continue
}
"*password:" {
send "$password\r"
expect eof
}
}
```
To use this script, save it as a file (e.g. `ssh-copy-id.expect`), make it executable (`chmod +x ssh-copy-id.expect`), and then run it with three arguments: the hostname or IP address of the remote server, the password for the remote user, and the path to the SSH key you want to copy over.
For example:
```
./ssh-copy-id.expect example.com password /path/to/my/key.pub
```
This script will automatically answer "yes" to any prompt about adding the remote host to the list of known hosts, and then enter the password for the remote user when prompted. Once the password is entered, `ssh-copy-id` will copy the public key to the remote server's authorized_keys file.
expect脚本里 su - root 报错 su: Authentication failure
在Expect脚本中,如果执行`su - root`命令时遇到`su: Authentication failure`错误,那通常意味着密码输入有误或者当前用户没有足够的权限来切换到`root`用户。
您可以尝试以下解决方法:
1. 确保您在Expect脚本中正确输入了`root`用户的密码。可以使用`send`命令发送密码给`su`命令。
```bash
#!/usr/bin/expect
spawn su - root
expect "Password:"
send "your_root_password\r"
interact
```
在上述示例中,使用`send`命令将`your_root_password`替换为实际的`root`用户密码,并添加`\r`来模拟回车键。
2. 检查当前用户是否具有切换到`root`用户的权限。确保当前用户是`sudoers`文件中允许切换到`root`用户的用户之一。
您可以使用以下命令来编辑`sudoers`文件:
```bash
sudo visudo
```
在打开的文件中,找到以下行:
```
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
```
确保当前用户所属的组在这行的前面没有被注释掉(没有以`#`开头),并且用户属于该组。如果需要添加用户到该组,可以使用以下命令:
```bash
sudo usermod -aG sudo your_username
```
将`your_username`替换为您要添加到`sudo`组的用户名。
请注意,执行`su - root`命令时,为了安全起见,密码不会显示在终端上。
如果上述方法仍然无法解决问题,请确保您的`root`用户密码正确,并且具有足够的权限来切换到`root`用户。
希望这些信息对您有所帮助!如果您还有其他问题,请随时提问。