linux脚本

MySQL (5-7) 安装脚本

匿名 (未验证) 提交于 2019-12-02 22:02:20
#!/usr/bin/python #coding=utf-8 #Larryd.Yin import commands import os import shutil import time import sys A = "A" B = "B" C = "C" a = "a" b = "b" c = "c" Y = "Y" y = "y" N = "N" m_name = "mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz" m2_name = "ql-5.6.44-linux-glibc2.12-x86_64.tar.gz" m3_name = "mysql-5.7.26-linux-glibc2.12-x86_64.tar" def jnsystem(): os.chdir("/usr/local/mysql") commandstatusoutput("mkdir log && chown -R mysql:mysql /usr/local/mysql") shutil.copy("support-files/mysql.server","/etc/init.d/mysql") msc = '/etc/init.d/mysql' mf = open("/etc/init.d/mysql","r") content = mf.read()

linux下MySQL停止和重启

匿名 (未验证) 提交于 2019-12-02 22:02:20
在linux下MySQL启动停止重启命令 一、启动 1、使用linux命令service 启动: service mysqld start 2、使用 mysqld 脚本启动: /etc/inint.d/mysqld start 3、使用 safe_mysqld 启动: safe_mysqld& 二、停止 1、使用 service 启动: service mysqld stop 2、使用 mysqld 脚本启动: /etc/inint.d/mysqld stop 3、 mysqladmin shutdown 三、重启 1、使用 service 启动: service mysqld restart 2、使用 mysqld 脚本启动: /etc/inint.d/mysqld restart 查看mysql端口是否已经使用,使用netstat -anp 命令查看服务器端口使用情况。 文章来源: https://blog.csdn.net/qq_42822007/article/details/90550643

Linux_(3)Shell编程(上)

匿名 (未验证) 提交于 2019-12-02 21:59:42
一、shell 简介 Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁。 Shell 既是一种命令语言,又是一种程序设计语言。 Shell 是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核的服务。 1.Shell 脚本 Shell 脚本(shell script),是一种为 shell 编写的脚本程序。 什么是脚本语言? 脚本语言是像剧本一样教计算机办某个事情的语言, 这类程序可以用文本编辑器修改,不需要编译,通常是解释运行的。 2.Shell 环境 Linux 的 Shell 种类众多,常见的有: Bourne Shell(/usr/bin/sh或/bin/sh) Bourne Again Shell(/bin/bash) C Shell(/usr/bin/csh) K Shell(/usr/bin/ksh) Shell for Root(/sbin/sh) …… Bash(Bourne Again Shell)是日常工作中使用最广泛的,也是大多数Linux 系统默认的 Shell。 在一般情况下,并不区分 Bourne Shell 和 Bourne Again Shell, 所以,像 #!/bin/sh,它同样也可以改为 #!/bin/bash。 #! 告诉系统其后路径所指定的程序即是解释此脚本文件的 Shell 程序。

自动化部署脚本--linux执行sh脚本

匿名 (未验证) 提交于 2019-12-02 21:59:42
自动化部署脚本文件目录: 运行主程序:./install.sh #!/bin/bash SCRIPTPATH=$(cd "$(dirname "$0")"; pwd) Install_log=$SCRIPTPATH/install_log.txt echo "***start install***" > $Install_log echo " workspace is $SCRIPTPATH" | tee -a "$Install_log" show_license() { } install_expect(){ } install_unzip(){ } install_killall(){ } install_snmp(){ } install_java(){ } install_activemq(){ } install_redis(){ } install_systemdlib(){ } install_postgres(){ } stop_firewalld(){ } auto_run_config(){ autostart.sh } #unzip simo and config simo unzip_simo(){ } run_simo(){ } exit 0 init-data.sh脚本如下: #!/usr/bin/expect set timeout 900 set

linux 脚本实现程序自动安装

匿名 (未验证) 提交于 2019-12-02 21:59:42
2017年06月21日 09:45:00 阅读数:391 linux 脚本实现程序自动安装 #!/bin/bash //设置脚本中所需命令的执行路径 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH // $? 是取得上面执行命令的返回值,一般正确为0,错误为1 if [ "$?" != 0 ] ; then //echo 为输出到屏幕 echo "Please check your need software" //exit 0 为强制终止脚本 exit 0 fi // 声明回滚函数(作用是删除解压出来的文件) rollback(){ rm -rf apache-tomcat.tar.gz rm -rf MySQL-client-5.5.31-2.rhel5.i386.rpm rm -rf MySQL-server-5.5.31-2.rhel5.i386.rpm rm -rf jdk-6u29-linux-i586-rpm.bin rm -rf mysql.cnf } echo "Please choose to install or uninstall? (Installation: 1 / Uninstall: 0)" //接收键盘输入

linux wifi热点启动脚本

匿名 (未验证) 提交于 2019-12-02 21:59:42
最近有关wifi热点的驱动,启动参数都调试完了,验证可以连接传输数据。 首先要在系统启动脚本中插入wifi驱动,配置wlan0的ip insmod /system/vendor/modules/ 8188eu.ko ifconfig wlan0 192.168 . 201.1 netmask 255.255 . 255.0 /etc/softat-server start & 今天就把wifi ap的start stop脚本给弄了一下。 #!/bin/ sh # # It is not safe to start if we don ‘ t have a default configuration... #echo " /etc/init.d/dhcp-server not yet configured! - Aborting... " #exit 1 ; test -f /usr/sbin/hostapd || exit 0 test -f /etc/hostapd.conf || exit 0 test -f /usr/sbin/dhcpd || exit 0 test -f /etc/dhcpd.conf || exit 0 case " $1 " in start) echo -n " Starting SoftAp server: " test -d / var /lib

基于linux下的shell变量

匿名 (未验证) 提交于 2019-12-02 21:59:42
变量即在程序运行过程中它的值是允许改变的量,变量是用一串固定的字符 来标志不固定的值的一种方法,变量是一种使用方便的占位符,用于引用计 算机内存地址,该地址可以存储scripts运行时可更改的程序信息。在 shell 中变量是不可能永久保存在系统中的,必须在文件中声明。 在 shell 中变量分为环境级变量,用户级变量,系统级变量, 环境级变量只在当前 shell 中生效, shell 关闭变量丢失, 用户级变量写在用户的骨文件中,只针对当前用户有效, 系统级变量被写在系统的配置文件/etc/profile中 变量即在程序运行时保存在内存中。 硬盘永久,内存临时的。 环境级: export A= 1 用户级: vim ~/bash_profile export A= 1 系统级: vim /etc/profile export A= 1 [root @localhost mnt] # echo $USER root [root @localhost mnt] # a=1 [root @localhost mnt] # ps 父级进程 PID TTY TIME CMD 2200 pts/ 1 00 : 00 : 00 bash 4833 pts/ 1 00 : 00 : 00 ps [root @localhost mnt] # vim file.sh 加入显示a的值并加入睡眠时间

linux自动登录脚本

匿名 (未验证) 提交于 2019-12-02 21:59:42
#!/usr/bin/expect -f set host 10.1.2.3 set user root set password 123456 #set timeout -1 spawn ssh $user@$host expect "*assword:*" send "$password\r" interact expect eof $ ssh root@10.1.2.3 root@10.1.2.3's password: $ whereis expect /usr/bin/expect 文章来源: linux自动登录脚本

[Linux]Shell脚本“syntax error: unexpected end of file”报错及处理

匿名 (未验证) 提交于 2019-12-02 21:59:42
项目在Window下开发,写了几个bash脚本移到Linux环境下使用bash运行,提示报错: syntax error : unexpected end of file 或者添加可执行权限直接运行脚本时提示: / bin / bash ^ M : bad interpreter : No such file or directory 可以看出shell脚本在linux下每行末尾多了一个‘^M’结束符,这是由于编码格式不同导致的。 vim 打开脚本,输入 : set fileformat = unix 然后wq保存,问题解决。 转载请标明出处: [Linux]Shell脚本“syntax error: unexpected end of file”报错及处理 文章来源: [Linux]Shell脚本“syntax error: unexpected end of file”报错及处理