The first time to write shell scripts, no experience, is to write directly, or to go through the process ( ̄▽ ̄) ~*
-----------------------------------------------------------------------
In general, three steps, let's do it with me.
-----------------------------------------------------------------------
First step: Create a file first
public. Sh
Step two: Write the script
#!/bin/Bashecho $1#进入SVN临时目录cd/tmp/svn/repo/ideapwd# Delete SVN project RM-RF $1#更新SVN项目svn Co svn:localhost/repo/idea/$1#复制war包到项目cp-RF ${1}/target/${1}.war/usr/local/data/$1/tomcat/webapps# into Tomcatcd/usr/local/data/$1/tomcat# stop Tomcat./bin/shutdown.sh# Delete root file rm-RF webapps/root/*#解压项目war包unzip-O webapps/$1. war-d webapps/ROOT#启动tomcat./bin/startup.sh# displaying tomcat boot information tail-F Logs/catalina.out
Knowledge Points:
1.#!/bin/bash: This sentence is used to define which SH interpreter to use to interpret the script, there are two, there is a time #!/bin/sh. So what's the difference between these two types of parties?
[Email protected] bin]# ll/bin/14: Bash/bin/sh- A
Through the above can see SH generally set to bash soft chain, in the general Linux system (such as Redhat), using the SH call execution script is equivalent to open bash POSIX standard mode, that is to say/bin/sh equivalent to/bin/bash--posix.
2.echo $1:echo is used to print in streets, which represents the first parameter passed in
Step three: Execute the shell script
SH publish.sh Hospital
Extracurricular topics:
1. If you want to use the same as the boot tomcal./startup.sh boot then you need to execute the command before executing the script.
chmod +x publish.sh
2. Remember the first line of #!/bin/bash on the top of Daming Lake? If you execute the following command, you can stop it.
Bash public.sh
Shell uses shell scripts to publish the project