1, case do with the execution of the option script:#!/bin/bashCase $ inXecho "X is selected";;*)echo "Please use X"EsacSecond, case combined while doing interactive script:#!/bin/bashWhile TrueDoRead-p "Enter Port of Chaoxingdata (d,1):" PortCase ${port} inDecho "Port=${port}"Read-p "Press ENTER to continue";;1)echo "Port=${port}"Read-p "Press ENTER to continue";;*)echo "Error input,you fool"Read-p ' type ' go ' to continue: ' Goif [! ${go} = go] | | [-Z ${go}]ThenExitFiEsacDoneShell
When a variable is evaluated in a script, you need to add a [] to the outside and set a $[email protected] tmp]# cat real_mem_used01.sh#!/bin/bashTotal= ' Free-g|grep Mem |awk ' {print $} 'Used= ' Free-g|grep Mem |awk ' {print $} 'Buffer= ' Free-g|grep Mem |awk ' {print $6} 'Cache= ' Free-g|grep Mem |awk ' {print $7} 'real_used=$[$USED-$BUFFER-$CACHE]pused=$[$real _used*100/$TOTAL]echo $PUSED%[Email protected] tmp]#[Email protected] tmp]# sh real_mem_used01.sh12%[Email protected] tmp]#Method Two
Synchronization script, in the 5th step to splice the host name of your own configuration1#!/bin/Bash2#1gets the number of input parameters, if there are no parameters, exit directly3Pcount=$#4 if((pcount==0)); Then5 echo no args;6 exit;7 fi8 9#2Get file nameTenp1=$1 OneFname=$ (basename $p 1) AEcho fname=$fname - -#3get parent directory to absolute Path thepdir=$ (CD-P $ (dirname $p 1); pwd) -Echo pdir=$pdir - -#4get the current user name +User=$ (WhoAmI) - +#5Loops A for((host=3; host5; ho
Tags: Restart started warning body Stop one result postLet's start with an example: Suppose you have a test service that can start, shut down, or restart test by command, the following script simulates this feature:#!/bin/bash#test.shcase $ in start) echo "Starting service ..." sleep 1 echo "started the service!!" ;; Stop) echo "Stopping service ..." sleep 1 echo "stopped the service!!" ;; Restart) echo "Restarting service .
Non-interactive password modification in Shell scripts and non-Password modification in shell scriptsToday, when I wrote a shell script, I found that the user's password needs to be set and the password is set to interactive. This is obviously not good in the script, So I went online to search for information, two common non-interactive password setting methods are found:1: Use chpasswdIn fact, chpasswd uses the user to enter the 'user name: password'
How to customize service scripts and how to create standard rpm service scriptsCustom Service script:
#!/bin/bash#myscript#chkconfig: 2345 90 20#description: Starts, stops and saves iptables firewallcase $1 in start) echo "start my script!!" sleep 1 ;; restart) echo "restart my script!!" sleep 1 ;; stop) echo "stop my script!!" sleep 1 ;; *) echo "please input start|restart|stop
Weblogic Start and Stop scripts and weblogic start scriptsStart weblogic
Determine whether to enable the service by using the port.
#! /Bin/bash # author: wjf # date: # test environment: wls1036 horizontal cluster v_curr_user = 'whoam' v _ start_user = uweblogic # ------------ user v_admin_url = http: // 10.10.71.106: 9001 # ------------ manage the server's urlv_dir_domain_bin =/weblogic/Oracle/Middleware/user_projects/domains/gyhr_domain/bin # -----
Special characters of shell scripts and special characters of shell scripts1. # comment ,#! Besides, echo $ {PATH # *:} parameter replacement does not represent annotation, numeric conversion, and echo $(2 #101011) 2 .; command Line separator. Multiple commands can be written in one line. echo hello; echo there3.; the Code for copying the terminate case option is as follows:Case "$ variable" inabc) echo "\ $ variable = abc"; xyz) echo "\ $ variable =
Webview Dynamic Injection of js scripts and webviewjs scriptsAfter the webview is loaded, add a local click event to all img tabs.
/** Function () {var objs = document. getElementsByTagName ('img '); for (var I = 0; I
Then
webview.getSettings().setJavaScriptEnabled(true);webview.addJavascriptInterface(new Object(){ @JavascriptInterface public void openImage(int i, String src) { ArrayList
Inject script code after page data is loaded
webvi
Mutt
# VIM/ROOT/.MUTTRC
Set sendmail= "/usr/local/msmtp/bin/msmtp"
Set Use_from=yes
Set Realname= "Moniter"
Set from=fuquanjun@xxx.com
Set Envelope_from=yes
Set Rfc2047_parameters=yes
Set charset= "Utf-8
4, the mail sends the test (S-mail title, a table plus annex)
Copy Code code as follows:
# echo "message content 123456" | Mutt-s "Message header test message"-a/scripts/test.txt fuquanjun@xxxx.com
The f
Let the code inserted into the innerHTML script run during ajax programming, we often need to assign the page content obtained by xmlhttp to a container (such as p, span, or td) through innerHTML, but there is a problem here, that is, if the page content we will assign to innerHTML contains scripts, these scripts, whether external scripts or internal
= yessetcharset = "UTF-8
4. Mail sending test (-s mail title,-a table with attachments)# Echo "Mail content 123456" | mutt-s "mail Title Test mail"-a/scripts/test.txt fuquanjun@xxxx.com
The following error message is displayed:
Msmtp: account default not found: no configuration file available
An error occurred while sending the mail. The sub-process has exited 78 ().
This email cannot be sent.
Solution:
Use msmtp to send a test:/usr/local/msmtp/bin/m
In ajax programming, we often need to assign the page content obtained by xmlhttp to a container (such as div, span, or td) through innerHTML, but there is a problem here, that is, if the page content we will assign to innerHTML contains scripts, these scripts, whether external scripts or internal scripts, may not be e
This problem may be insignificant or even negligible in some cases, but sometimes it is very serious, and it is likely that our program will not get the expected results. Therefore, we need to solve this problem.If you have read MSDN, you will find that not all scripts inserted into innerHTML cannot be executed. If the script tag of this script contains the defer attribute, IE will correctly execute these scripts
These days I have been studying shell scripts and writing some system load and CPU monitoring script programs. Without nagios monitoring software, as long as the server can access the Internet, you can send an email to remind the administrator of the system load and CPU usage. I. install the shell script and write some system load and CPU monitoring script programs in linux these days. Without nagios monitoring software, as long as the server can acce
As more and more sites evolve into "Web 2.0" apps, the amount of JavaScript increases. this is a performance concern because scripts have a negative impact on page performance. mainstream browsers (I. e ., IE 6 and 7) block in two ways:
Resources in the page are blocked from downloading if they are below the script.
Elements are blocked from rendering if they are below the script.
With more and more websites involving "Web 2.0" applications,
These days I have been studying shell scripts and writing some memory monitoring script programs. Without nagios monitoring software, as long as the server can access the Internet, you can send an email to remind the administrator of the system memory usage.1. Install a mail client msmtp software (similar to a foxmail tool) in linux)1, download installation: http://downloads.sourceforge.net/msmtp/msmtp-1.4.16.tar.bz2? Modtime = 1217206451 big_mirror
Original article: Python scripts as a replacement for Bash utility scripts
From: http://www.oschina.net/translate/python-scripts-replacement-bash-utility-scripts
Translator: enixyu,Showme,Onion noodles
For Linux users, the reputation of command line is quite high. Unlike other operating systems, the command line is a t
content 123456" | Mutt-s "Message header test Message"-a/scripts/test.txttest@126.com
Monitoring system memory using free command:
1, use the free command to view the Linux system memory usage: (in m)
Copy Code code as follows:
# free-m
(Execution results are the following style)
Copy Code code as follows:
Total used free Sharedbuffers Cached
mem:3952 34145380168484
-/+ buffers/cache:2760 1191
SWA
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.