I need to launch server executables from terminal. They are running through wine (because those executables are for Windows) in the background. If I launch them normally, from Terminal, those work without any problem.
Now I'm trying to make CGI (bash) script and launch servers from website, but script doesn't launch processes. I thought that it has something to do with wine, but no, script doesn't launch any processes at all.
I'm building that system on Ubuntu 12.04.1 LTS, after that scripts would go onto Debian server.
So, the question is: is it even possible to run background process from CGI scripts? If yes, would you please explain how?
A CGI program is like any other program, except that it is supposed to run quickly and to follow the CGI protcol (in particular, regarding to stdout output).
As with any other Linux program, you can (subject to limitations and permissions on your system) run processes, using syscalls like e.g. fork(2), execve(2) and many others.
I suggest to read a good Unix programming book like Advanced Unix Programming abd Advanced Linux Programming. We can't teach all that here in a few minutes.
You could also run processes using the library system(3) and popen(3) functions (of course these functions are implemented using syscalls, inside GNU libc)
Don't forget the stateless property of CGIs; you may consider using FastCGI or SCGI instead.
(A program started thru wine from a CGI might fail, e.g. because it has no X11
server to talk to; For C# programs, consider Mono on Linux).
Another possibility could be to run Windows in some VM, and have your CGI interact with such virtualized Windows programs. Not knowing Windows, I have no idea about the issues of such an approach.
Related
Is there any software working like this?
Runs as a standalone program. No install is needed. Thus, can be used as an Ansible module.
After running the program in a remote Linux machine, I can open up a web browser, then open a web page provided by the program. The program provides features similar to file explorer, IDE-level code editor, debugger, etc. In terms of debugger, there is already similar one; gdbgui.
There is another way such as Gnome, KDE or X11. However, these requires much packages to be installed. I don't want they be installed, because my Linux machines are kept to be small and secure.
You might consider having some terminal emulator running inside a browser. Such things exist, e.g. libonion has oterm as an example application. Then you can do all the things that a command line interface thru a unix shell provides (of course, you won't be able to run GUI applications, e.g. X11 clients such as GTK or Qt applications).
You could also consider some webmin like stuff.
Notice that you don't need to have a desktop environment on a remote Linux machine. Most of them (e.g. internet servers) have only command line interface.
Learn more about X11: you could have an X11 server on your laptop (e.g. under Windows if so needed) and run remotely X11 clients (that is GUI applications) with ssh -X on your remote Linux system.
However, these requires much packages to be installed. I don't want they be installed, because my Linux machines are kept to be small and secure.
I don't understand that requirement. On my VPS, running in some OVH datacenter, I do have X11 client applications (notably emacs). I don't believe that lowers the security of my system, and the disk space consumption for X11 applications and libraries is small enough these days. And of course I use standard commands (like cp(1), mv(1), rm(1), grep(1), find(1), less(1), file(1), sed(1) ....) to manage files. Any graphical file manager is useless (and I never use them, while using Unix since 1986)
You really should learn how to use the command line on Linux. It is incredibly powerful.
I am using Ubuntu 13.10. Is it possible to debug a windows executable under Linux?
I've tried gdb, but it always throw me this error message.
/bin/bash: line 0: exec: /some.exe: cannot execute: Permission denied
I don't have much experience with this but, I think, what you're looking for is winedbg. Initially, it should allow you to debug Win32 applications in Linux.
I suggest you try the IDA Debugger (cross platform debugger).Hope it helps.
You are trying to execute a program designed to run in a OS, from within another one, which could be using a complete different processor than a x86.
In order for a executable program to be run in a specific OS, these modules or services must exist:
A module that can understand the binary code of the executable program and translate, if needed, into binary code of the host processor.
A service that can intercept any instruction identified as a system call, and emulate its behaviour using host resources
A module that is able to load, parse and prepare a process block to acommodate the new "guest" process
This is just for executing a program. To debug it, you also need a service that can interact with the above mentioned modules/services in order to control execution of that program.
That said, you can probably debug an EXE file using some utility from the Wine project, asumming your Ubuntu is running on a x86 processor. Take a look at it.
http://www.winehq.org/
Also, I recall VirtualBox offers some sort of debugging help for processes running on the guest OS, but I'm not sure about this.
No, it is NOT possible to debug a Windows executable under Linux.
Are there any equivalent scripts run on boot on mac osx (/etc/rc.d etc.)?
such as we can found in linux:
https://stackoverflow.com/questions/3036/files-and-scripts-that-execute-on-boot
This is generally handled by launchd. Exactly how you do it (LaunchAgent vs LaunchDaemon) depends on whether you want it to be run as a system process or a user process. See Daemons and Services Programming Guide for details.
I need to develop applications for Linux but I don't want to either program on Linux (I already have all my "precious" tools setted up) or test it on Windows using some kind of POSIX for Windows and hoping that if runs well on that runs well on real Linux.
What's the better choice? Preferentially I want to use Eclipse IDE for compile/run/debug and run my programs on a Linux distribution that is running on a local VM or remote.
Right now I'm using a similar approach, but for Java Web Service testing on a remote server. Perhaps that's the way to go?
Edit:
In order to beter explain what I want, here is the steps that I want to follow:
Program in C, for POSIX compliant systems, using Eclipse on Windows
Make small tests on Windows, perhaps using Cygwin (this is not mandatory it's just to be quicker)
From my Windows Eclipse, I want to run/debug my application on a real Linux environment (could be a VM or a remote machine) and, preferentially, redirect the application stdout to my computer. The Linux machine only exists in order to garantee that everything runs ok, no need of even open it.
One thing that I didn't mentioned: all of the applications are command line, no need for GUI, just input from a shell and read the output.
First, install Linux in a virtual PC like VirtualBox or VirtualPC or something from vmware.
Then configure Eclipse for remote development. That allows you to run tools (like the debugger, the compiler suite, etc) on Linux from your Windows desktop inside of Eclipse. You edit the files just like you're used to, you debug as if the app was running local on Windows, etc. Eclipse will do the plumbing.
Remote server is the way to go. But most people have a powerful enough machine to run a 32-bit Linux distro in Virtualbox which is better than a real remote server because you have full control of setup and config.
But install cygwin including GCC and use that to run initial compile (and maybe unit tests) locally. Also, do use Valgrind on your Linux VM to help you produce cleaner code.
I'm programming something and I need debugging support on most operating systems (linux, windows, macosx).
This is what the program is supposed to do:
- fork a new program (platform specific program - like adobe reader on windows, but evince on linux)
- monitor for exceptions (handled and unhandled)
- execute a predefined function based on the exception
So basically I need some kind of a debugger, a library which I can use to make this possible. I would then start a debugger, start a program, and monitor for the exceptions.
It would also be great if I could execute & monitor for the exceptions over the network. So let's say my program is running on computer A and is connected to computer B (via ssh, RDP, whatever) and I would start a new program in computer B from computer A, and also monitor and react based on the exceptions from the computer B.
So my question is: is anything like that already written in form of a perl/python/whatever library or something similar. If it is, I would very much like to know about it.
Just to make this more clear: the linux only library call for this (just not supporing the network part) is ptrace system call.
gdb
There is a built in python debugger.pdb