如何把sshpass命令bash脚本里面呢? [英] How to put sshpass command inside a bash script?

查看:1028
本文介绍了如何把sshpass命令bash脚本里面呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行bash脚本里面sshpass命令,但它不工作。

I am trying to run a sshpass command inside a bash script but it isn't working.

如果我运行正常工作的终端相同的命令,但它破坏了脚本中没有。

If I run the same command from the terminal it works fine but ruining the script with it inside doesn't.

#! /bin/bash

sshpass -p 'password' ssh user@host command

我知道的安全问题,但其并不重要了。

I am aware of the security issues but its not important now.

有人能帮忙吗?我失去了一些东西。

Can someone help? Am i missing something.

感谢

推荐答案

不要这sshpass 在命令行中得到的绝对路径 sshpass ,并在bash脚本替换它。

Do which sshpass in your command line to get the absolute path to sshpass and replace it in the bash script.

您也应该可能做的命令相同您正试图运行。

You should also probably do the same with the command you are trying to run.

的问题可能是它没有发现它

The problem might be that it is not finding it.

这篇关于如何把sshpass命令bash脚本里面呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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