I am creating a bash script in Linux (ubuntu) that starts an ant build from a build.xml file, located in another directory. My folder structure looks like this:
myBashScript.sh
/project56
/http
build.xml
When I try to call this build file from myBashScript.sh I get the following error:
"Buildfile project56/http/buildfile.xml does not exist!"
I tried the following:
sudo ant -buildfile project56/http/build.xml
sudo ant -v project56/http/build.xml
sudo ant -v fullPathStartingFromHome/build.xml
But I keep getting this error. The funny thing is, when I try to invoke ant (using the first option listed above) from the terminal in the same location that myBashScript.sh is in, the build starts fine.
Can someone help me with this?
Thanks in advance,
Robert
Fixed it, turns out another cd to project56 buried somewhere in my script was screwing things up.
Related
So I'm basically wanting to get a script to run on system boot. It's basically an SSH callback. I've tried a few ways that I've gotten to work in the past on other distributions, but having a little bit of difficulty here.
First thing I've tried was adding the /path/to/script.rb to /etc/rc.local. However, this file does not exist on the latest version of Kali Linux. I tried to create it and replicate my old Ubuntu rc.local file, but it didn't run on system startup.
Next thing I tried was creating an executable bash script in /etc/init.d/, following the update-rc.d script.sh defaults and making the file executable. Restarted and nothing. If I run the script manually, it works. I tried to redirect the output to a file in the tmp folder, but it doesn't appear that there are any errors from what I'm understanding.
Are there any other ways to get an auto run script started other than these two methods? Seem to be the most common way to get this working, but it's just not doing it for me.
Add script to
/etc/init.d
Run command:
chmod 755 /etc/init.d/script
Run command:
update-rc.d script enable
I have recently moved from Window 7 to Windows 10 and I cannot get my makefiles to work anymore.
I have been using the GNU Make for Windows
The first thing that I noticed was that it had started treating Windows folder dividers (backslash characters '\') as line continuation characters, so I modified the 'clean' section as shown below to use forward slash '/' characters instead:
clean:
del $(ObjDir)/*.o
When I call make -ftest.mak clean I get the following error which suggests it is now trying to run in a MinGw/Cygwin environment:
c:\Test\Source>make -ftest.mak clean
del obj/*.o
/usr/bin/sh: del: command not found
make: *** [clean] Error 127
I do have MinGw folder on my PC (which I have renamed to stop make looking for it) and I can't see any 'MingGw' related environment variables in my Cmd.exe environment or PATH
How can I get make working so it doesn't try executing sh under Windows?
Is there some configuration parameter somewhere that makes it call sh instead of cmd.exe?
Update: Just tried running make -d which logs debug output. It looks as though it is using my Git folder as some sort of root folder:
Must remake target `clean'.
del obj/*.o
CreateProcess(NULL,C:/Program Files/Git/usr/bin/sh.exe -c "del obj/*.o",...)
Putting child 0x006e7fc0 (clean) PID 7234712 on the chain.
The cleanest way is to specify SHELL on command line.
make -ftest.mak clean SHELL=cmd
will do the job. ndk-build will do that for you, see your ndk-build.cmd. Don't try to run ndk-build bash script on Windows. The scripts in NDK may go amoc when you run them on Windows in bash.
Nasty conclusion to this problem.
make looks through the PATH environment variable for anything containing usr/bin. It just so happens that since I also installed Git on my Windows 10 PC, Git added the following folder to PATH:
C:\Program Files\Git\usr\bin
Adding any path with the substring "usr\bin" will cause make to try running sh instead of cmd.exe on Windows.
My solution: Remove the C:\Program Files\Git\usr\bin from my PATH.
Update: I changed the name from usr\bin to user\bin but make still finds sh.exe within that folder. In the end I renamed sh.exe to _sh.exe within the Git\usr\bin folder.
I am trying to run the following command:
/A/B/C/D/E/RAILS_ENV=staging rake deploy:resque
And the get the following error
-bash: /A/B/C/D/E/RAILS_ENV=staging: No such file or directory
But when i run the command directly from the folder it works nicely.
I don't quite understand how it is supposed to work
Thanks.
cd /A/B/C/D/E && RAILS_ENV=staging; rake deploy:resque
I would like to do the following on system startup on debian:
./home/user/bittorrent_sync_i386/btsync
I downloaded the application here:
http://download-new.utorrent.com/endpoint/btsync/os/linux-i386/track/stable
The error I get is:
"bash ./home/user/bittorrent_sync_i386/btsync: File or directory not found."
I only can do:
cd /home/user/bittorrent_sync_i386/
./btsync
I would just like to run the application on startup on debian. I also found this:
http://xmodulo.com/how-to-automatically-start-program-on-boot-in-debian.html
But how would I modify this script to do what I want? Sorry I am quite new to debian.
If you launch
/home/user/bittorrent_sync_i386/btsync
Without the dot. Does it work better ?
I have a ant target where I successfully use a sshexec-task to install a server using tomcat on OpenSuse 11.
My problem comes when I try to run a script that start the newly installed server.
I need to do this as root, so I use a task as this:
<sshexec host="${tss.hostname}"
username="${username}"
password="${password}"
trust="true"
Command="/usr/local/bin/foo/bar/tomcat/bin/startup.sh"
failonerror="false"/>
The problem with this is that I need to run the script from the folder where it is located, as it finds CATALINA_HOME and JAVA_HOME from that location. And the path "foo/bar" will change over time so I do not want to set it permanently.
I just want to change my running path to the correct one.
As I failed to start the server like that, I wanted to investigate a bit and changed the script so I used "CommandResource="cmd.txt" instead of a direct command. I thought I could use this to set CATALINA_HOME before I started the server and go around the problem that way.
This is the outcome when using cmd.txt:
[sshexec] Connecting to foo-bar:22
[sshexec] cmd :
[sshexec] cmd : cd /usr/local/bin/foo/bar/tomcat/bin
[sshexec] cmd : pwd
[sshexec] /root
[sshexec] cmd : echo $PATH
[sshexec] /usr/java/jdk1.6.0_27/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
[sshexec] cmd : export CATALINA_HOME=$PATH:/usr/local/bin/tibco/tss/4.5.0/tomcat
[sshexec] cmd : echo $PATH
[sshexec] /usr/java/jdk1.6.0_27/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
This shows that neither the cd nor export command have any effect.
I suspect I need to change the rights for ssh. I have read that I may need to change in .ssh/config. But I do not know how or where...
So, to sum this long question up short:
What do I need to do to be able to run my startup.sh as root from the correct tomcat/bin folder with a ant script that is run in Jenkins?
I've found that "cd" works when done on the same line...
<sshexec host="${tss.hostname}"
username="${username}"
password="${password}"
trust="true"
Command="(cd /usr/local/bin/foo/bar/tomcat/bin; startup.sh)"
failonerror="false"/>
I haven't actually used this to run a shell script but I'll often have ant change directories and then run GIT commands.
Yeah I also faced the same problem. The cd command doesnot work from sshexec. Alternative is to put all the commands in some install.sh file and scp it to the remote machine. And then use sshexec commandresource to execute this file on the remote machine. Hope this helps.