Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the Windows equivalent of a UNIX shell script?

I want to have an executable file that will call some other programs. The way I would do this in Linux is with a simple bash script that looks like this:

#!/bin/bash
echo "running some-program"
/home/murat/some-program arg1 arg2

What's the best way to do this kind of thing under Windows?

like image 737
Murat Ayfer Avatar asked Nov 17 '08 21:11

Murat Ayfer


People also ask

What is shell equivalent in Windows?

Windows Terminal is a modern host application for the command-line shells you already love, like Command Prompt, PowerShell, and bash (via Windows Subsystem for Linux (WSL)).

Does Windows have Unix shell?

Under Windows, one easy way to access a Unix command line shell is to download and install Cygwin. The installer has lots of options, but if you just go through using the defaults, you should end up with an icon on your desktop that will load up a Unix shell.

Is PowerShell the same as Unix shell?

PowerShell is superficially similar to Unix shells. PowerShell has aliases for many of the commands you are used to in Unix, like ls, rm, cp, mv, etc. However, the way that the cmdlets behind the aliases work is quite different.

What does Windows use instead of bash?

In windows 2007 and above, Powershell is a built-in program. Before that, it has to be installed as a separate program. Linux and Unix systems mostly use Bash, and it is used from the very first day in Linux and Unix operating systems.


4 Answers

Take a look at PowerShell, which is the closest you will get to a true scripting language like you have in Unix. Other than that, for simple things such as simply runnning an application, take a look at Windows command script/MS-DOS batch files.

like image 139
Scott Dorman Avatar answered Sep 19 '22 00:09

Scott Dorman


You could go with either an old school batch file (http://en.wikipedia.org/wiki/Batch_file) or you can go with a brand new shiny Windows PowerShell script (http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx).

I use batch for simple operations and PowerShell for complex scripts that also involve data processing.

like image 24
Bogdan Avatar answered Sep 20 '22 00:09

Bogdan


There are a number of scripting options on windows:

  • Batch files
  • VBScript/CScript/JScript (very powerful when combined with WMI)
  • PowerShell
  • You could install Perl, Python, or other engine
  • You can install unix tools, via Cygwin for example, to get make most of the common unix commands available in windows as well.
  • Since we're all (mostly?) programmers here, there's nothing stopping you from making a .exe file to do what you want.
like image 23
Joel Coehoorn Avatar answered Sep 18 '22 00:09

Joel Coehoorn


You can use a Windows batch file. Find more information in the Wikipedia article.

like image 37
Eric Wendelin Avatar answered Sep 18 '22 00:09

Eric Wendelin