我想用一个bash脚本通过ssh在远程服务器上创build一个数据库。 像这样的东西
#!/bin/sh ssh [email protected] 'MysqL -h example.com -uroot -pMYPASSWD -e "CREATE DATABASE $1;"'
所以我在terminal上可以运行它
$ myBashScript nameOfNewDatabase
如何在linux中激活TCP Fast Open
在bash脚本中使用curl并curl:(3)在URL中find非法字符
inputlinux命令的颜色
System.getenv没有得到〜/ .bash_profile中定义的variables
Bash脚本:使用bash脚本中的“脚本”命令logging会话
如何在zsh中填充数字variables(也可能是bash?)
如何在sh脚本中find时间
如何检查文件是否用curl下载
以下脚本可以远程执行任意命令
#!/bin/bash # call MysqL on a Remote Server to execute the given command # show usage and exit usage() { echo "$0 server sql-command" 1>&2 exit 1 } # check number of arguments if [ $# -lt 2 ] then usage fi # get server name and sql command server="$1" sql="$2" # copy command to a temporary file tmpsql="/tmp/sql$$" echo "$sql" > $tmpsql # copy command file to server scp $tmpsql $server:$tmpsql # run command remotely with removing command file afterwards ssh $server "MysqL -uroot -pPASSWORD < $tmpsql;rm $tmpsql" # remove local copy of command file rm $tmpsql
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。