Linux-I want to write a. sh file to replace the original script running with phpxxx. php.

Source: Internet
Author: User
I used phpxxx. php to run this php script. in linux, I want to use. xxx. sh to replace it. I wonder if it is feasible? Php xxx. php is used to run this php script.

In linux
I want to use./xxx. sh instead of above

Is it feasible?

Reply content:

Php xxx. php is used to run this php script.

In linux
I want to use./xxx. sh instead of above

Is it feasible?

Feasible,

#!/bin/bash# author: gm100861PHP=/usr/local/php/bin/php$PHP youphpfilename.php

You want to execute the php script directly.

1. Add # At the beginning of xxx. php #! /Usr/local/php/bin/php2.chmod + x xxx. php3../xxx. php

The shell you are using.

If it is bash, there is no good way to pass the file name to shell and then call php to run it.

For zsh, You can edit. zshrc and use the alias-s command to specify the command to be executed when you directly enter *. php. For example:
Alias-s php = 'php' # Run in shell input *. php
Alias-s php = 'vim '# open it when shell input *. php
Alias-s php = 'php-l' # Check the syntax error when entering *. php In shell

Yes. It can be called in the same shell script.php ***.php
You can also use crontab to specify the execution time and period.

Http://segmentfault.com/q/1010000003731015/a-1020000003732913

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.