How to call a .sh file from UiPath??
How to call a .sh file from UiPath??
You probably need to do it from within a Powershell script. Have a search online plenty of articles.
You can use Invoke Powershell Script from within UiPath.
As @richarddenton rightly mentioned already, you can employ PowerShell to run a bash shell script.
Feel free to revert for any clarifications.
I am still not clear, please check the below screenshot to get more details on what exactly I am looking for
Now, kindly suggest how I can resolve this?
Thank you for the details.
Here, you are trying to create a 0 kb file using touch command which is a shell based command(UNIX) hence it will not work on windows platform.
I assume that you are trying to create a new file in the ~ directory in a windows system(if linux, please specify the same) and for that you can use PowerShell.
Please refer the below mentioned command to create a new file in windows
> New-Item c:\user1\AnEmptyFile.txt -ItemType file
Mention the same command in the Invoke Powershell activity and do change the path of the file as per your requirement.
Feel free to revert for any further clarifications.
The command which you have given is running fine, but I need to run a shell command.
Can you please suggest how can I do the same?
Have tried using “Start Process” with the .sh file in the arguments? I know you can run other scripts like batch and vbscripts with that method.
You could probably use Powershell too. Just look up the syntax and create a .ps1 file to call that runs your .sh file.
I am having issues getting UiPath to run Win10 native bash commands.Screenshots show bash works from the command line, works invoked from an AutoHotkey script, but fails from a UiPath workflow. Any help you can give me getting going with it would be great.
I’m afraid I should have logged more of my results, but on several occasions PowerShell (invoked from a workflow) asked for a Windows Credential. Stepping through workflows, the Output window has on some occasion shown that bash is not recognized as a command. This leads me to believe I may have to give UiPath permission to access bash, but I have not found anything in the forum or StackOverflow yet to suggest how to do it.
I believe that any workflow that would simply execute “bash -c ls” would get me most of the way there, be it from “Start Process”, “Run Power Shell Script”, or anything.
The Microsoft docs on security policies and local Win10 accounts are sufficiently opaque to me that I’ve not been able to determine whether I need to set a security policy for UiPath to use bash or not.
Here’s some screenshots:
Okay, bash works …
Calling a bash script from an AutoHotkey script works …
But UiPath can’t, apparently, access it as I have it configured.
Once again, thanks for your help. Also, Richard, Clayton, any thoughts?
Have you checked if bash.exe is located in the System32 folder? Maybe it’s in a different folder? I would look for the physical .exe file you want to call, then use the fullpath. If you can’t find it, then I’m not sure.
Thanks, Clayton, it’s where it’s supposed to be (System32). Calling the fullpath doesn’t work from UiPath either …
My suspicion (from the screen shot saying the command isn’t recognized) is still that UiPath on my system doesn’t have access to bash (it obviously has access to System32). If I can figure out if this link can help maybe I can get there. I’m pretty new to Win10, and so far I haven’t been able to get “full control” for bash security policy applied to Administrator, even though I changed the owner from “Trusted Installer” to “Administrator”. Still trying . At least it’s a worthwhile exercise.
What if you create a powershell (.ps1) file and call that which calls the commandline?
invoke-expression "cmd bash -c ls"
invoke-expression "cmd ‘c:\windows\system32\bash.exe’ -c ls"
Then call the Powershell.
Thanks, Clayton, no joy so far.
The script “script6.ps1” is:
invoke-expression "bash -c ls"
From UiPath, running my workflow that executes this:
Not only does UiPath not see bash, it doesn’t recognize the Set-ExecutionPolicy I have in place. So something is out of kilter for security policies for UiPath, I think. I’ll keep trying, and thanks!
Edit: Here’s what my UiPath program had to say when I passed “powershell Get-ExecutionPolicy -list”:
From the prompt:
I see you did invoke-expression "bash -c ls”. Did you try it with cmd? like invoke-expression "cmd bash -c ls”
Oh well. I wish I was an expert on this stuff!
Thanks, Clayton, invoke-expression “cmd /c bash -c ls” also works from the PS prompt, but fails in UiPath.
I think I’m beating a dead horse here.
UiStudio is 32-bit. C:\Windows\System32\bash.exe is 64-bit and does NOT have a corresponding executable in SysWOW64.
I guess it’s Cygwin or Git bash for now - I haven’t tried Cygwin lately but Git bash works fine.
Here’s a shot from the file selection dialog from the Start Process activity:
From File Explorer:
But the dead horse whimpers:
Workflows, executable, test.csv and sample scripts included in zip file.
BashingIt.zip (1.9 MB)
Best of luck, all feedback appreciated.