How to launch exe from PyCharm Terminal? - terminal

I'm trying to launch Blender directly from PyCharm Terminal on Windows. I first use cd 'C:\Program Files\Blender Foundation\Blender 3.1\' to get into the directory containing the executable I need, and this works okay. Then I call blender.exe and expect it to launch Blender executable from the directory I am currently in. But for some reason it launches the older (2.93) version from another folder. The same steps work just right when I do all the same in the Windows cmd.exe. I've thought that the problem could be with the Python interpreter, but I use Python interpreter that goes with Blender 3.1 in the PyCharm project settings. What am I doing wrong and how can I run the exact executable I need?
P.S. I know that I can write a simple script in Python, use subprocess module, and get almost the same result, but anyway I'd like to use the launch from the Terminal if it is possible.

Related

How can I run Clozure CL in the Windows command line?

I'm trying to install Clozure CL using their guide, and it wants me to add the files ccl and ccl64 to my path, but they have no file extension and Windows doesn't know how to run them.
I eventually looked in the file and it was headed by #!/bin/sh. As far as I know, I would need external software to get these files to run.
I want to know if there is some other workaround for setting up Clozure CL more easily, and if there isn't, what would I need to be able to run these files directly from the command line?
It appears that all the scripts do is run the file wx86cl64.exe in the main ccl directory as long as you're on Windows. So, all one needs to do is add the ccl directory to their path to achieve success.

How can I use Python to interact with the Ubuntu terminal for windows 10?

I am running compiled c code on the Ubuntu subsystem for Windows. I would like to automate this process with a Python script that can open the terminal, send and read commands as well as closing the window.
I am trying this on Python 3.6 in Windows 10. I thought it was going to be the same as interfacing Python with the CMD but all the things I try are not yielding results. I want to know if anyone has tried to automate processes with the Ubuntu subsystem for Windows and how can that be achieved.
First, I had to find the .exe that launches the Ubuntu app, since it's downloaded from the microsoft store.
Using OS simply gives me the following result without opening the terminal.
import os
os.system(r"C:\Program Files\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_1804.2019.521.0_x64__79rhkp1fndgsc\Ubuntu.exe")
1
Also using subprocess will open the terminal. But parting from there, how can I give it commands and read the outputs?
import subprocess
subprocess.Popen([r"C:\Program Files\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_1804.2019.521.0_x64__79rhkp1fndgsc\Ubuntu.exe"])
I think there's a few things worth mentioning here.
Firstly, I don't think you need to use Python at all. If you want to schedule your compiled C code to run at a particular time (or linked to some other condition etc.), you can do all of this within WSL. I would suggest using cron which already comes with Ubuntu. It's a scheduling daemon that can execute tasks at specified intervals.
Secondly, if you want or need to use Python to achieve this (for whatever reason), I suggest you install a second version of Python within WSL. This will allow you to easily run whatever shell commands you want e.g. to execute your compiled C code. You don't need to worry about opening an Ubuntu window and then closing it etc. Personally I would actually go further and say that you should ditch your Windows 10 Python and just go with the WSL Python - it makes a lot of things much easier, especially if you're already familiar with Linux or are using WSL a lot for other tasks anyway.
Lastly, if you still really need to automate this from Windows 10, I suggest you use the Windows Task Scheduler to schedule a .bat file which opens bash (WSL) and executes a command as per the following link:
How to run program on ( ubuntu bash windows 10 ) from windows task scheduler
(or if you don't need to schedule it, you can instead just execute the command from Python)
Hope that helps!

Mac OS install application and run a script on startup

I'm looking for a way to package my application with the added requirement that I need to add a python script to always run on startup.
What I've been trying so far is having a .pkg that installs the .app into the applications folder and adds the python script (wrapped in a .plist launch daemon) to the user's LaunchAgents folder.
I've tried a lot of different things, but for whatever reason the python script runs fine on the command line and just doesn't work when running through launchctrl. I could go into what the problems were, but I feel that would make more sense as a separate question.
I am wondering if I should be using a different approach to achieve my goal of installing the app in Applications and having a python script run on boot. Is there a more standard solution that I am missing perhaps? Thanks.

How to get an ocra application to be accepted by antiviruses

Alright, so judging by the title (if you practice Ruby), you should know what Ocra is. If you don't, here's a brief explanation:Ocra is a command added to the command prompt in order to convert ruby programs to executable. So .rb to .exe.
In order for one to convert a ruby program to executable, they would type in the command prompt:
cd <locationOfFile>
ocra rubyProgram.rb
and then ocra would run the program and when that's done, it runs some scripts which completes the program. Then afterwards the executable version of the program would be in the same directory as the original ruby version and the same name. So recently I noticed that my antiviruses are removing the program from my computer telling me it's a bloodhound. It's getting really annoying and I'm getting tired of having to use ocra over and over again just to remake a program. I have two antiviruses: McAffee and Symnatec; so that means double the security. What can I change so that my antiviruses ignore the program?
Tell them to ignore/exclude the directory that the .exe is being built into.

Equivalent of double-clickable .sh and .bat on Mac?

I am distributing a Java program where I want a double-clickable file to run
java -cp MyProgram.jar;MyLib.jar my.program.Main
On Windows I simply distribute a .bat file, for *nix an executable .sh file. Problem is, double-clicking the .sh file just opens it up in a text editor on Mac. What should I do for Mac?
On mac, there is a specific extension for executing shell scripts by double clicking them: this is .command.
For Java applications on Mac, you really should use Apple's Jar Bundler (in the Developer Tools/Applications/Utilities folder; really a symlink to /usr/share/java/Tools/Jar Bundler). It lets you make a proper OS X double-clickable app, including setting preferences for e.g. using the Mac toolbar, JVM version, graphics system, OS X app metadata and classpath/resources.
You can use a .sh (Shell Script), after all MacOSX is Unix!
The answer about using the Jar Bundler tool is correct, but if you want to use a .sh file, make sure the unix permissions are set properly to something like 755 with CHMOD, and make sure the first line contains the path to a shell installed by default on Mac OS X. Also note that even with the +x bit set, it may still ask the user whether they want to open it or run it.

Resources