I'm devellopping a WebApplication (for Tomcat) using netbeans on Windows 7. For the Webapplication to run I need to run a insall-script once.
This script (*.bat for windows and *.sh for linux is included in my war-file (WEB_INF).
Now everytime I deploy the WAR-file and want to run the script on linux I have to call
chmod +x install.sh
first.
Is there a way that this script can be made executable by default? I don't want to have to execute some extra commands after the deploy to make the script executable.
For clarification:
I'm not new to Linux and I know how to set executable-rights on files. That's not the problem. My problem is: What do I have to do, so that this script is executable right after tomcat deployed my *.war-file (unpacked it). If I would be using Linux for development as well, I would try to set the rights according in my sources (maybe I'll try it when I have a little more spare time). But I am using Windows and netbeans.
Are there any attributes I can set to achive my goal, or is it possible to achive this using ant?
By the way: Are there security related issues with this approach? The script looks for java executable and calls a javabased GUI-installer...
Change permissions during initialization of the application, the following:
String [] command = {"/bin/chmod","+x",full_path_to_install.sh};
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec( command );
pr.waitFor();
allows your application to set executable permissions before using the script. It is not executable right after tomcat deployed your war file but just before your application uses it.
Assuming you are invoking the same "install.sh" everytime, you need to set the execute bit only once. Also, the executable bit need to be set only for the user (the command you have provided will set it for everyone).
chmod u+x install.sh
Related
I try to execute a java application at startup in a yocto based linux device. I added a script at /etc/init.d/etic and made it executable. If I call at the shell /etc/init.d/etic start or /etc/init.d/etic stop the application is started an stopped as expected. Then I called on the shell update-rc.d etic defaults and the symlinks were created. According to what I found on the web, this should be enough, but somehow the application is not started. What did I miss? How could I check what is going wrong or is there any minimal example which should work which I can try to extend?
Well, often such issues are due to a different environment when executing the start script by hand, as compared to when it's being run from the init system. For instance, your .profile and .bashrc won't have been sourced, when running from the init system.
You can use eg logger to easily log things from your init-script, and this rather easily find out what goes wrong.
So I have a script that is launched on login via rc.local. The script calls a few other scripts to be launched and ran. However the console says that the file and/or directories could not be found. When I run the script manually after the login it works just fine. I have even tried to add a small delay so that I know that the system logged in. Any idea why this is and how to fix it?
Sorry if my answer is a bit vague but from what I understand is that the scripts require to be run via admin privileges. Let me elaborate, when the system starts it runs a set of specific scripts and this differs from distro to distro. Therefore, I'd check ~/.bashrc /etc/profile.dand most importantly ~/.bash_login. See what you can do there. Personally I added it here ~/.config/autostart worked fine. Don't forget to create a .desktop file.
Hope this helps
This question already has answers here:
Executable file generated using GCC under cygwin
(5 answers)
Closed 7 years ago.
Let me tell you my problem. I've a shell script which execute a Linux executable. I don't have access to the source code of this exe.
When I run the script on the Linux machine, there is no problem.
But, if I try to run the script on my Windows laptop, using cygwin, I have the error "cannot execute binary file".
There is any solution ?
Thanks !
From https://stackoverflow.com/a/4144536/5704102:
"... Cygwin is a compatibility layer, which aims to implement as much as possible of the POSIX and Linux APIs within Windows. This means that programs have to be compiled specifically for Cygwin ..."
What does this script look like? Is it a bash script? If so, you may want to try sh <scriptfile> in Cygwin. If this doesn't work, and it is a bash script, make sure you have sh.exe. Type sh and hit tab twice to check.
Another potential issue if it is a bash script is that you don't have something installed that Cygwin requires to run the script. Make sure all the commands the script is trying to run will work. If not, you may have to run the Cygwin installer and install whatever is needed to run the script.
Also, you may want to check permissions.
If the file has an exe extension, it SHOULD work on Windows unless it was compiled for 64 bit architecture and you're running a 32 bit OS. Otherwise, you could be missing some .dll files that the executable relies on.
Edit:
If this is the contents of your script:
echo START
/oper/file.exe
then it's likely you have the incorrect path. Cygwin paths typically start with /cygdrive/c/ in Windows. Go to where the file exists and type pwd to get the correct path, then modify your script accordingly.
Content of Script.sh in oper folder :
echo START
/cygdrive/c/Users/jo/oper/file.exe
In Cygwin terminal (in the right folder):
sh Script.sh
(Path updated)
I have a c++ executable which I monitor using supervisord. And I made supervisord as startup process. When I reboot, supervisord and my executable are working fine (functionally). And Stdout_log file is created in tmp (which is also fine). But the log file is empty.
And In my executable I am running few bash scripts which I do it using system(), but It is also failing.
So I have two issues
log file is empty
system() is failing
I can related these issues to some permission, but no clue to fix it. Looking for some suggestion
Thanks
If your executable cannot be run as root itself, run it as as non-privileged user instead.
Either configure all of supervisord to run as another user by setting the [supervisord] user option:
[supervisord]
user = wwwdata
or set a user parameter for your executable in it's [program:x] section:
[program:yourprogram]
user = wwwdata
On an OpenSuSE linux machine, I want to run a script when the machine is booted. As the script does not start a service, is /etc/rc.d the correct place for the script?
Thanks.
That's where I've always put them. There are several scripts in rc.d already which don't actually start a process. However, you need to write it in a similar fashion to the other startup scripts - have a look at a few to see how they are set up. Specifically, you should make sure that it's possible to run the script using /etc/rc.d/myscript start.