Linux shell scripts execute in other directories

Source: Internet
Author: User

eg

For example, when running rails's own server under Linux, this command is required rails_evn=production rails S is not a bit verbose, every time to hit so many words, can not tolerate, fortunately, we have shell script help. Create a script of your own:

Touch a rails_s.sh and then use VIM to edit the following, save.

# !/bin/bash Rails_evn=production Rails S

Execute the following command:

Echo $PATH

The display path information is as follows:

Echo $PATH/home/sophia/.rvm/gems/ruby-2.1. 3/bin:/home/sophia/.rvm/gems/ruby-2.1. 3@global/bin:/home/sophia/.rvm/rubies/ruby-2.1. 3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/ Sophia/.rvm/bin:/home/sophia/.rvm/bin:/home/sophia/.rvm/bin

You can see that there is a/usr/local/bin, put the written rails_s.sh into the/usr/local/bin, and then change the permissions:

sudo chmod 5 rails_s.SH

You can now use rails_s under the project directory (eg:/var/www/blog/) . The sh command executes the script to start the server:

[Email protected]:/var/www/ashelf$ rails_ssh= booting Webrick3.2.  A  in production on http://0.0.0.0:3000= Call with-D to detach= Ctrl-c to Shutd Own server

Linux shell scripts execute in other directories

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.