Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to execute a .jar file from command line using just the .jar file name.
For e.g.
Instead of
java -jar <jarname>.jar -a <a> -b <b>
I want to run
<jarname> -a <a> -b <b>
Is it possible. If possible how? I don't want to use batch script, since I am using apache commons cli for command line arguments parsing.
You can't do that.
What you can do, is write a shell script that does the command you don't want to do, or generate a executable wrapper. In both cases, the solution is OS-dependent. On windows, there is launch4j, on MacOS, you can create an app (that is a folder with a particular structure).
UPDATE
Actually, creating an app on MacOS is not a solution for using in a command line.
Is it possible.
No. It is not possible.
(Well ... if your shell supports a aliases or shell functions, then the user could write one. For example alias foo='java -jar foo.jar' But that's not really the same.)
For something like this, I would recommend writing a wrapper script. If you are using a platform with a POSIX compliant shell (sh, bash, etc) then it is not difficult to avoid mangling the command line arguments; e.g.
#!/bin/sh
java -jar /path/to/foo.jar "$#"
or
#!/bin/sh
java -cp /path/to/foo.jar com.acme.frobnicator.Main "$#"
For the record, "mvn" (which you cited as an example) is implemented as a shell script / batch file.
This seems to me like XY problem, that's why I'm trying to answer bit differently to what you asked...
Let say you have myjar.sh script, which will "convert"
myjar.sh -a <a> -b <b>
to
java -jar abc.jar -a <a> -b <b>
(this is doable, you can see it is Stephen Cs answer)
You just have a fear, that it will break your command line arguments parsing. The only possible way is to test and if you find it is not working we can deal with that...
Related
I cannot use cscope in vim. The commands below are not work
:cs find s {name}
:cs find c {name}
...
The error code is about "E259 No matches found..." but I add and execute the database exactly.
I use :cs show to show the database I use, and there is nothing wrong.
Here are the command I build:
find "$(pwd -P)" -name "*.c" -o -name "*.h" > cscope.files
cscope -Rbqk -i cscope.files
and I set the :cs add /path/to/database/cscope.out in .vimrc
By build and add database with absolute paths, I think I can get the database in every c files in any subfolders.
The weird thing is, I can use cscope and find the symbol by:
cscope -Rqk -i cscope.files
I think something wrong about my vim but I don't know how to figure out.
Please, I need some helps.
You should consult cscope-intro help tag:
:help cscope-intro
(in the vim screen)
to get the full help to the interace of vim to cscope. It requires to build the database to use from your source files first, so probably the used database is empty and that's the reason you don't find anything.
Vim's cscope commands are an interface (as it is told in the help page I recommended you to use) to the cscope shell command, so the most probable cause that it doesn't work is that you have not established a database to consult when using it.
I am trying to run mathematica with a terminal interface. This is so that I can submit a mathematica program as a batch job to a high performance computing cluster.
Currently I load mathematica using:
module load mathematica/9.0.1
and then type
mathematica
to run it. This however opens a GUI interface which I don't think can be submitted as a batch job. Is there anyway to achieve this baring in mind I have no sudo privileges etc
The documentation on the text-based interface to Mathematica is here:
http://reference.wolfram.com/language/tutorial/UsingATextBasedInterface.html
I know this thread is old but I want to share this for future users:
I have used Mathematica with a terminal interface. You need to write a Wolfram Language Script, which is simply a .wl file with Mathematica code in it. Once you have written your file, just execute it in your terminal like this:
Running the script file on Windows:
$ "%ProgramFiles%\Wolfram Research\Mathematica\11.1\wolfram" -script file.wl
Running the script file on Mac:
$ /Applications/Mathematica.app/Contents/MacOS/WolframKernel -script file.wl
Running the script on Linux:
$ wolfram -script file.wl
First of all, I don't know Batch programming at all. I came across a FIND command in a tutorial I was reading about OpenCV
http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html
find ./positive_images -iname "*.jpg" > positives.txt
It basically is supposed to copy all the relative paths of all the jpeg files inside positive_images directory to positives.txt file. I ran this in CMD(as Administrator) and got the following:
What is the meaning of Access Denied? I don't want to learn Batch Programming for this as I am already busy in my project. Please give me a simple-to-understand solution.
The referred tutorial uses the bash find command.But you're executing the Windows find command.Download from somewhere the windows port for the unix command put it in your directory and call it like
.\find.exe .\positive_images -iname "*.jpg" > positives.txt
mind also the windows path separator slashes.
you can use this port for example -> http://unxutils.sourceforge.net/
(probably there's a newer port but this should do the work)
I am using windows XP operating system and cygwin is installed in my C drive.
I need to login to cygwin directly to my directory path which contains a makefile and also a bash script called build.sh in the same directory. So i modified the original cygwin.bat file and added the line as shown below.
#echo off
C:
chdir C:\cygwin\bin
bash --login "/cygdrive/E/scheme_31july/build/build.sh"
When i double click on this bat file i could see my script executing but not on cygwin shell but on windows cmd shell as a result I get errors for "make" command like "No rule to make target" as make comes bundled with cygwin.
And when I explicitly login to cygwin using default cygwin.bat file and execute my script by giving following commands in cygwin shell the script executes without errors.
Basically I want to write a bat file so that I can keep it anywhere in my PC and instead of manually openeing the cygwin prompt and typing commands like:
$ cd /cygdrive/E/scheme_31july/build/
$ sh build.sh
it should happen automatically. I sit possible to do so.
Regards,
Harshit
No rule to make target sounds more like make being executed in the wrong directory. make itself seems to be available and running as intended.
Try this:
bash --login -c "cd /cygdrive/E/scheme_31july/build/ && sh build.sh"
This should start a --login session (which should give you access to all the settings and tools you'd expect in a cygwin prompt environment), then execute the given shell command, which is the cd and sh you asked for. You could also write those two lines to a separate script file, and pass the name of that to bash instead of the full path to build.sh.
You could also try to cd into C:\scheme_31july\build in the bat file and then execute bash from there. Not sure whether bash will try to change path upon entering the login session. You can try whether things work without the --login, both for this approach and the one above.
#echo off
C:
cd C:\scheme_31july\build
C:\cygwin\bin\bash.exe ./build.sh
I'm not sure whether you want the session to turn interactive after that or not. In the above case, bash will terminate after the script completed, and might even close the window. You might have to add a read into build.sh to avoid that. If you want bash to turn interactive after executing some command, you can try using the --rcfile option of bash to execute some commands and then turn interactive.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a Postgresql installed via Homebrew and after a crash I can not start server anymore..
if I do
$ pg_ctl start
I get
pg_ctl: no database directory specified and environment variable PGDATA unset
If I do
$ pg_ctl -D /Library/PostgreSQL/data start
I get
pg_ctl: could not open PID file "/Library/PostgreSQL/data/postmaster.pid": Permission denied
Everything was working just fine and then.. out of the blue, this.
The data folder above has permissions set at "Everything" for postgres user and "None" for everyone..
Path looks fine (in my ~/.bash_profile)
export PATH=/usr/local/bin:$PATH
When you first started Pg, did you let homebrew start it for you, or did you manually start it with pg_ctl ? I ask because I'm guessing you probably need to start and stop Pg using homebrew scripts and/or using launchd rather than directly via pg_ctl. I don't use homebrew (or Mac OS X much) but a quick search suggests that homebrew installs of Pg are usually started and stopped via launchd and ~/Library/LaunchAgents/org.postgresql.postgres.plist .
If you want to manage it manually:
What user does homebrew usually run PostgreSQL as? If you're launching Pg via pg_ctl you need to run it as the right user. From vague memory of other discussion I've seen about homebrew here, it's probably a user named postgres or postgres_ . Double-check using:
ls -ld /Library/PostgreSQL/data
and see what the owning user is, then run:
sudo -u postgres_ pg_ctl -D /Library/PostgreSQL/data start
... replacing "postgres_" with the owner of the datadir.
I suspect the reason you're getting permissions errors is that you probably didn't recursively apply the changes. Please don't; run Pg as the correct user instead.