Start shell in bat in windows

Source: Internet
Author: User

In windows, to start the shell in bat, because cygwin is required to execute the daily scheduled task, a scheduled task is installed in cygwin to complete the task. However, in windows, it may be troublesome. Considering that windows has a scheduled task, if you can schedule the task, start the application or bat script on time every day. Because the script is a shell script, it cannot be executed directly in windows. It can only be executed through cygwin. Therefore, you must start cygwin in bat and write the bat file: 1 @ echo off2rem change to d: 3d: 4rem change the dir5chdir D: \ cygwin \ bin6echo "begin... "7rem start the cygwin and run the shell file.8D: \ cygwin \ bin \ mintty.exe/home/scripts/webFunc a problem occurs: After cygwin is started, the command cannot be run, which has been plagued for several days. I still don't know why the shortcut can be run directly, but the "ls, find, mkdir" and other commands cannot be found after bat is started .. At first, I thought it was bat that I needed to pass some parameters to cygwin. I checked its shortcuts and found no special parameters. It was not until now that we realized that it was an environment variable problem, so we added cygwin \ bin after the path of the environment variable. The problem was solved. In a small part, find is used in my shell script, while find is also available in windows. Therefore, the system uses the find command in windows by default, so an "parameter error" exception is always reported. After changing find in shell to/user/bin/find, the problem is solved. Fortunately, there are not many scripts, so there are two or three places to use find. After the change, it is executed normally. In addition, mysql is used in the script. Therefore, you need to install mysql and add environment variables. Porting from linux to windows sounds very simple. There are still many problems encountered during the process. Another problem is the path problem in the code. When I first wrote the code, I wrote all the search and configuration paths to the dead. When I transplanted them, I only needed to manually change them to windows to recognize them. Pay more attention in the future, and try to conform to posix standards.

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.