executable

Is there a Perl equivalent to Python's `if __name__ == '__main__'`?

别等时光非礼了梦想. 提交于 2019-12-03 04:21:44
Is there a way to determine if the current file is the one being executed in Perl source? In Python we do this with the following construct: if __name__ == '__main__': # This file is being executed. raise NotImplementedError I can hack something together using FindBin and __FILE__ , but I'm hoping there's a canonical way of doing this. Thanks! unless (caller) { print "This is the script being executed\n"; } See caller . It returns undef in the main script. Note that that doesn't work inside a subroutine, only in top-level code. Chas. Owens See the "Subclasses for Applications (Chapter 18)"

Is it safe to recompile an executable while it's running?

时间秒杀一切 提交于 2019-12-03 04:14:18
问题 What happens if I recompile an executable while it's running? Does the operating system read all of the executable's contents into memory when it starts running it, so it will never read the new executable file? Or will it read sections of the new executable file thinking it hasn't changed, leading to possibly undefined behaviour? What if I have a script running which repeatedly invokes an executable in a loop, and I recompile the executable while the script is running. Is it guaranteed that

How to write and executable Windows .exe manually (machine code with Hex editor)?

北慕城南 提交于 2019-12-03 01:41:12
问题 I'd like to know how is it possible to write something as simple as an Hello World program just by using an Hex Editor. I know that I could use an assembler and assembly language to this at a near machine level but I just want to experiment with really writing machine code in a toy example such as Hello World. This could be a simple DOS .COM file that I can run on DOSBox. But it would be nice if someone could provide an example for an .EXE file for running it directly on my Windows PC. This

PyInstaller creates slow executable

萝らか妹 提交于 2019-12-03 00:41:21
I'm using PyInstaller to create a single executable of a python program using PyQt. It creates the .exe and runs fine, but takes between 15 to 20 seconds to start. I thought I could get by with creating a splash screen so the user would at least know something was happening, unfortunately, the splash screen doesn't show up any quicker than the program window itself. I also created the same program as -onedir, the program does start quicker, but this isn't really an option for distribution. If anyone has any ideas on what is slowing down the execution and ways to speed things up I would

How to get output of exe in python script?

◇◆丶佛笑我妖孽 提交于 2019-12-03 00:28:49
When I call an external .exe program in Python, how can I get printf output from the .exe application and print it to my Python IDE? gimel To call an external program from Python, use the subprocess module. The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. An example from the doc ( output is a file object that provides output from the child process.): output = subprocess.Popen(["mycmd", "myarg"], stdout=subprocess.PIPE).communicate()[0] A concrete example, using cmd , the Windows command line interpreter with 2

Running .sh scripts in Git Bash

孤人 提交于 2019-12-02 21:41:19
I'm on a Windows machine using Git 2.7.2.windows.1 with MinGW 64. I have a script in C:/path/to/scripts/myScript.sh . How do I execute this script from my Git Bash instance? It was possible to add it to the .bashrc file and then just execute the entire bashrc file. But I want to add the script to a separate file and execute it from there. Let's say you have a script script.sh . To run it ( using Git Bash ), you do the following chmod +x script.sh ./script.sh You can change the chmod to the executable permissions that you want. Those can be found here . Note: The chmod only has to be run once .

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

对着背影说爱祢 提交于 2019-12-02 20:32:28
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

How do you compile an Erlang program into a standalone windows executable?

我与影子孤独终老i 提交于 2019-12-02 17:41:38
Richard of Last.fm over at metabrew has ported his apps to Erlang . It was also done by riak, couchdb and others. He mentions extracting the needed parts, or including the whole VM into the distribution. Main trait here is: the program does not require Erlang to be installed on the target machine. So the question is, how do you, step by step, package an Erlang program into a windows (and, less important, linux) executable? P.S. I've seen the SAE project, and I've read all the relevant questions here. None answer my question. Create a portable version of Erlang (for example using method from

Is it safe to recompile an executable while it's running?

江枫思渺然 提交于 2019-12-02 17:31:44
What happens if I recompile an executable while it's running? Does the operating system read all of the executable's contents into memory when it starts running it, so it will never read the new executable file? Or will it read sections of the new executable file thinking it hasn't changed, leading to possibly undefined behaviour? What if I have a script running which repeatedly invokes an executable in a loop, and I recompile the executable while the script is running. Is it guaranteed that future iterations of the loop will invoke the new executable, and only the result of the invocation

Can't execute javac or other command line applications in Java using ProcessBuilder under Windows 7

亡梦爱人 提交于 2019-12-02 16:38:18
问题 I'm trying to execute javac from Java using ProcessBuilder but i get no output and nothing happens. I tried reading the input stream (as there is a bug where the process hangs if i don't read it) but still no results. I originally passed all required parameters to javac but it was not working, so i simplified it down to just javac (which should print the help message). i tried running "C:\Windows\System32\cmd.exe /c C:\\"Program Files\"\Java\jdk1.6.0_23\bin\javac.exe" "C:\\"Program Files\"