添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
聪明的足球  ·  PISquare·  2 月前    · 
活泼的生姜  ·  Error: Update WP ...·  7 月前    · 
会开车的仙人掌  ·  Example usage for ...·  1 年前    · 

i installed a Cygwin ( https://www.cygwin.com/ ) in my windows server and now I can execute bash script in windows. I want to write script that implement bash script in my powershell script.
When I start this command in powershell

I see that it's a few command that are not recognize from powershell - rm et.c. When i start the script in cygwin terminal, i can execute without problem. I send too the bash script:

!/bin/bash  
# define general stuff  
host=.  
certdir=/cygdrive/l/$host.  
certdir_local=L:/$host..  
outcert_cygwin=/cygdrive/c/certbot  
storepass=.  
  # rm old pfx file  
  rm $outcert_cygwin/letsencrypt.pfx  
  # convert the cert to some tomcat shizzle  
  openssl.exe pkcs12 -export -out $outcert_cygwin/letsencrypt.pfx -inkey $certdir/privkey.pem -in $certdir/cert.pem -certfile $certdir/chain.pem -password pass:$storepass  
  # change permission of the cert  
  chmod 644 $outcert_cygwin/letsencrypt.pfx  
  # additional info, for server.xml  
  echo "Make sure the contents of c:\certbot\tomcat_server_config.txt are"  
  echo "added to the tomcats server.xml"  
  echo "Exiting."  
  exit 0  
# else  
#   echo "Exiting."  
#   exit 0  
# exit 0  

Can anybody help me how this command would be recognized from powershell? For example the command rm is available. See you screenshot:
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.

Try this:

Open Window's File Explorer. Find a file that uses the ".sh" extension. Right-click it and select "Open with". Select "sh.exe" and "Always use...".

Assuming that your PATH variable points to when you have Cygwin installed you should be able to run your shell scripts without running bash.

Ian Xue

============================================

If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.