# Fatal error with Execute shell in project

**URL:** <https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694>\
**Category:** Ask a question\
**Created:** [March 3, 2022, 10:11am UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694 "2022-03-03T10:11:52Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![RachelCohen](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@RachelCohen](https://community.jenkins.io/u/RachelCohen)\
**Post date:** [March 3, 2022, 10:11am UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/1 "2022-03-03T10:11:52Z")

</div>

Hey,  
I have a problem:  
When I **create a project** and click on **“Build”** and select **Execute shell** and **build the project** -  
I got an error in the _console output_:

```auto
Started by user Rachel Cohen
Running as SYSTEM
Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\test_again
[test_again] $ sh -xe C:\WINDOWS\TEMP\jenkins1793137690508028130.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessImpl.create(Native Method)
	at java.lang.ProcessImpl.<init>(Unknown Source)
	at java.lang.ProcessImpl.start(Unknown Source)
Caused: java.io.IOException: Cannot run program "sh" (in directory "C:\ProgramData\Jenkins\.jenkins\workspace\test_again"): CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessBuilder.start(Unknown Source)
	at hudson.Proc$LocalProc.<init>(Proc.java:254)
	at hudson.Proc$LocalProc.<init>(Proc.java:223)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:997)
	at hudson.Launcher$ProcStarter.start(Launcher.java:509)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:144)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
	at hudson.model.Build$BuildExecution.build(Build.java:199)
	at hudson.model.Build$BuildExecution.doRun(Build.java:164)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522)
	at hudson.model.Run.execute(Run.java:1896)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)
Build step 'Execute shell' marked build as failure
Finished: FAILURE

```

**The system cannot find the file specified**  
**FATAL: command execution failed**

If anyone knows what the problem is- it’ll help me a lot  
thank you!  
Rachel

---

<div class="post-metadata">

**Author:** ![StealthDJ](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/stealthdj/32/438_2.png) [@StealthDJ](https://community.jenkins.io/u/StealthDJ)\
**Post date:** [March 3, 2022, 10:26am UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/2 "2022-03-03T10:26:04Z")

</div>

That looks like you’re trying to run a ‘shell’ step on a windows node, which is unlikely to succeed, unless you have a specific shell executable installed there (in which case, it needs to be in the %PATH% of the node.

For windows nodes, you’d generally be looking at running either ‘bat’ or powershell steps for scripts.

Tony

---

<div class="post-metadata">

**Author:** ![RachelCohen](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@RachelCohen](https://community.jenkins.io/u/RachelCohen)\
**Post date:** [March 7, 2022, 7:19am UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/3 "2022-03-07T07:19:51Z")

</div>

Thank you - It was help me a lot!

---

<div class="post-metadata">

**Author:** ![lenemapse](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@lenemapse](https://community.jenkins.io/u/lenemapse)\
**Post date:** [February 28, 2023, 3:53pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/4 "2023-02-28T15:53:37Z")

</div>

It happens because Jenkins is not aware about the shell path.  
In my case the solution was:  
In Manage Jenkins → Configure System → Shell, set the shell path as

> C:\Windows\system32\cmd.exe

After doing this change, it works for me.  
Hope it helps!

---

<div class="post-metadata">

**Author:** ![TZ123](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/tz123/32/5198_2.png) [@TZ123](https://community.jenkins.io/u/TZ123)\
**Post date:** [August 15, 2023, 12:30am UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/5 "2023-08-15T00:30:36Z")

</div>

Thank you - this is very helpful 🙂

---

<div class="post-metadata">

**Author:** ![HarshDhanani](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/harshdhanani/32/5390_2.png) [@HarshDhanani](https://community.jenkins.io/u/HarshDhanani)\
**Post date:** [September 4, 2023, 4:26pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/6 "2023-09-04T16:26:16Z")

</div>

Right, it works for me as well.

---

<div class="post-metadata">

**Author:** ![H-Ali27](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/h-ali27/32/5925_2.png) [@H-Ali27](https://community.jenkins.io/u/H-Ali27)\
**Post date:** [October 24, 2023, 7:57pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/7 "2023-10-24T19:57:02Z")

</div>

@lenemapse it worked for me. thank you lenemapse

---

<div class="post-metadata">

**Author:** ![Bouba](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@Bouba](https://community.jenkins.io/u/Bouba)\
**Post date:** [November 8, 2023, 12:17pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/8 "2023-11-08T12:17:04Z")

</div>

it worked fine.Thanks!

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [November 8, 2023, 12:19pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/9 "2023-11-08T12:19:28Z")

</div>

Changing `Execute shell` to use the Windows command processor seems counter-intuitive to me. Wouldn’t it be better to use the “Execute batch command” step instead of “Execute shell”? The “Execute shell” step is generally used for programs that are POSIX compatible shells.

---

<div class="post-metadata">

**Author:** ![soumyaswain9658](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/soumyaswain9658/32/6921_2.png) [@soumyaswain9658](https://community.jenkins.io/u/soumyaswain9658)\
**Post date:** [February 3, 2024, 5:08am UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/10 "2024-02-03T05:08:18Z")

</div>

Hi if you use in jenkin in window platfrom then use on below

// To run Maven on a Windows agent, use  
bat “mvn -Dmaven.test.failure.ignore=true clean package”

---

<div class="post-metadata">

**Author:** ![Afor](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@Afor](https://community.jenkins.io/u/Afor)\
**Post date:** [April 1, 2024, 2:47pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/11 "2024-04-01T14:47:58Z")

</div>

This worked for me. I was skeptical about adding the SSH plugin due to issues relating to ‘CSRF vulnerability and missing permission checks in SSH Plugin allow capturing credentials’ and ‘Missing permission check in SSH Plugin allows enumerating credentials IDs’

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [April 1, 2024, 3:17pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/12 "2024-04-01T15:17:39Z")

</div>

> [@Afor](#):
>
> I was skeptical about adding the SSH plugin

I agree that it is wise to be skeptical about adding the [ssh plugin](https://plugins.jenkins.io/ssh/) due to known security vulnerabilities ([SECURITY-2093](https://www.jenkins.io/security/advisory/2022-05-17/#SECURITY-2093) and [SECURITY-2315](https://www.jenkins.io/security/advisory/2022-05-17/#SECURITY-2315)).

As far as I know, there is nothing in the ssh plugin that will allow a shell step (“sh”) to run on Windows computers. I’m surprised that installing the ssh plugin made any change to how Pipeline steps execute on Windows agents.

Windows agents almost always use “bat” and “powershell” steps to perform their operations. Some users may have found ways to configure their Windows computers to also include a program that is compatible with “sh” and runs on Windows, but that is not the typical way that Windows agents are used.

---

<div class="post-metadata">

**Author:** ![Afor](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@Afor](https://community.jenkins.io/u/Afor)\
**Post date:** [April 1, 2024, 3:57pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/13 "2024-04-01T15:57:14Z")

</div>

Thank you so much. Your comments was very useful

---

<div class="post-metadata">

**Author:** ![vinayvmathad](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/vinayvmathad/32/8459_2.png) [@vinayvmathad](https://community.jenkins.io/u/vinayvmathad)\
**Post date:** [May 31, 2024, 3:16pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/14 "2024-05-31T15:16:27Z")

</div>

after making this changes i am able to execute but i am not able to see what i am printing in executable shell

 ![Screenshot 2024-05-31 204602](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/7/7f39c88546b466e31641cfc0c662cb6b646692b2.png)

---

<div class="post-metadata">

**Author:** ![vinayvmathad](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/vinayvmathad/32/8459_2.png) [@vinayvmathad](https://community.jenkins.io/u/vinayvmathad)\
**Post date:** [May 31, 2024, 3:19pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/15 "2024-05-31T15:19:05Z")

</div>

![Screenshot 2024-05-31 204736](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/c/ca31f54cdbef21969d96ba5c78f5c9adbda85ea2.png)  
I can see only success. But where can i see “Hi jenkins” note

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [May 31, 2024, 11:57pm UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/16 "2024-05-31T23:57:37Z")

</div>

> [@vinayvmathad](#):
>
> i am not able to see what i am printing in executable shell

Please stop trying to use “Execute shell” on a Windows agent. “Execute shell” is used for Unix agents like Linux, macOS, FreeBSD, OpenBSD, and Solaris.

Please use the `bat` or `powershell` steps on Windows agents.

---

<div class="post-metadata">

**Author:** ![vinayvmathad](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/vinayvmathad/32/8459_2.png) [@vinayvmathad](https://community.jenkins.io/u/vinayvmathad)\
**Post date:** [June 3, 2024, 6:34am UTC](https://community.jenkins.io/t/fatal-error-with-execute-shell-in-project/1694/17 "2024-06-03T06:34:04Z")

</div>

Thanks for the information
