IntelliJ - Running Program as Sudo - intellij-idea

Developing a program on OSX using Java and IntelliJ. Deals with network sockets and ICMP. Hence, the program needs to be run as root or sudo'd on OSX. Program runs fine from a terminal window outside IntelliJ under sudo. However, I would like to debug and run it from IntelliJ (V9). In IntelliJ it errors (I need root privs to enumerate network devices). I know how to pass program and VM parameters in IntelliJ but now how to hit Run and/Debug and have it run under sudo? What is needed is basically sudo java ...... MyProgram instead of java ..... MyProgram Any ideas or workarounds.

I came out with an answer and wanted to share it just in case anyone else runs into this. To solve the problem, I took my cue from what I do with QT & QT Creator when doing network programming.
On OSX, I opened up a terminal window and cd'd down to/Applications/IntelliJ IDEA 9.0.3.app/Contents/MacOS. There you will find a file called idea which launches the IDE. I ran that as sudo (sudo ./idea). That took care of permissions on anything Intellij launched and I could debug and step through my code as needed.
sudo /Applications/IntelliJ IDEA 9.0.3.app/Contents/MacOS/idea
Since this is a dev machine and I am in control of it security is not an issue in this case.
Hope it helps someone else out.

Inside a terminal:
sudo -s
give access to the root user.
from there you could run the Idea IDE using the script:
/Applications/IntelliJ\ IDEA*/bin/idea.sh
and in this way I'm able to work on network where permission errors where printed before.

Debugging of sudo programs is disallowed by the operating system unless the debugger is running as root, for security reasons.
So, even if you can figure out how to get IntelliJ to use sudo it won't do you any good.

I know this is not what OP directly asked -
In case someone needs to do this on Linux (Ubuntu), e.g. in order to update Idea, just run from command line:
sudo /usr/local/bin/idea
Only make sure once the Update and Restart is finished to actually close Idea and start it normally

I agree with #Darron, it is not recommended to execute IntelliJ with sudo.
You can execute with IntelliJ terminal instead.
I maintain my project in IntelliJ. When I need to execute a unit test that requires sudo access, I just open IntelliJ terminal and type:
sudo gradle test
Good luck!

Related

Chmod from IntelliJ on Windows?

I'm using PyCharm on Windows. How can I set executable bit or modify other permissions like Linux chmod? I found this only and nothing suitable in plugins but still hope there's a better solution then switching to Linux console for that purpose.
I ran into the same issue, but I wasn't very eager to install yet another plugin. If you happen to use Git, you can do it from PyCharm's terminal using the following command:
git update-index --chmod=+x path-to-your-file

setting up monodevelop in xfce

I use this solution to have a VNC desktop session with a remote Ubuntu PC https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-16-04
I want to setup monodevelop on this machine. I followed the instructions and am able to run monodevelop and write code, however when I attempt to run it I get "Could not connect to the debugger". I tried various solutions suggesting changing environment variables to force monodevelop to use xterm and it did not work, however I'm not positive I did it correctly as the solution was meant for gnome and the modifications to the command for XFCE were not clear to me. At this point I'd be willing to get paid support, but I'm not even sure where I could find any for my use case. Does anyone have experience getting monodevelop to work on XFCE? If not what is the best environment for getting it going (ideally a way where I could remote in too). I'm very accustomed to the RDP workflow where I can actually troubleshoot on a development server and be very close to the real world environment to get things running, then check-in and deploy. I think there are a lot of platform differences with monodevelop so I really really really want to develop on Ubuntu (remotely).

problems with ubiquity/success_command Ubuntu 14.04

I want to automate the Ubuntu installation (a fully unattended installation without questions). I also want to run a script right after the installation is finished.
What I did is that I managed to have a fully unattended Ubuntu installation. I am doing this by providing a pre-seed file and using boot parameters to preseed the questions that are asked before the preseed file is loaded. The installation went okay but the problem lies with running the script right after the installation completion. I am using Ubuntu 14.04 LTS desktop version thus I am not using the late command as I have read that it won't be noticed by the installer. Instead, I am using the Ubiquity/success_command. I have the following code at the end of my pre-seed file.
ubiquity ubiquity/success_command string \
mkdir /target/dev-master/; \
cp -r /cdrom/dev-master/* /target/dev-master/; \
chroot /target bash /dev-master/SCRIPT;
The problem is nothing happens. I think the command went unnoticed as well.
I am not sure if I am approaching the problem correctly.
What am I doing wrong ?
Is there any other alternatives that might provide the desired result ? Any help would be appreciated and thanks.

Gnuradio companion not installed after running build-gnuradio script

I tried installing Gnuradio 3.7.9.2 using build-gnuradio script and apart from a few hiccups due to some packages (which I installed and re-ran the script again) , the script completed its run successfully (I enabled the verbose option of the script to check the output). I even added the PYTHONPATH to the .bashrc script after completing the installation. When I tried launching gnuradio-companion though, it doesnt recognise the command.
:~$ gnuradio-companion
The program 'gnuradio-companion' is currently not installed. You can install it by typing:
sudo apt-get install gnuradio
So, I was wondering whether I need to install grc separately after the build-gnuradio script installation ?. I apologise if this is too simple, I have tried the installation many times and searched the web for problems like this. To the best of my efforts, I was not able to find any. It would be great, if anyone can point to any existing question similar to this, or guide me in fixing this issue. Thank you.
It is advised to use PyBOMBS to install GNU Radio. Installing Out-of-Tree modules (OOTs) will be much easier afterwards. As for your problem: Did you check if your $PATH variable (echo $PATH) contains /usr/local/bin/? This should be the default installation path for a non-system install of GNU Radio.
Alternatively you can try to run /usr/local/bin/gnuradio-companion.

How can I run xsp4 as a background process on linux?

Is there an easy way to get xsp4 running as a background process on a linux server?
When I run xsp4 I get this:
xsp4
Listening on address: 0.0.0.0
Root directory: /test
Listening on port: 80 (non-secure)
Hit Return to stop the server.
So if I quit the terminal I am running it from it stops the server.
Do I have to write a daemon to do this? Or is there already something in place that I am missing?
Thanks
You have a couple of options. If your problem is terminal closing, then screen can be simple solution (just run screen xsp4, then Ctrl+A,D and you can close terminal). If the method you have used suits you, then use it -- however xsp will die after terminal closing. xsp should be generally used for debugging, production solutions are FastCGI or apache module, so these are daemons "by definition".
I had to use Mono for a demo that I had to show, and faced the same problem. My workaround was:
xsp4 --nonstop &
Note: It will show the initial information and if you hit enter, it will continue running. You can also exit the terminal if you want and it will continue as well.
you can do install the xsp4 in the terminal
sudo apt-get install mono-xsp4
then
go to your project Folder where the Asp project saved and type in the terminal
xsp4