Yogesh
Yogesh

Reputation: 57

Execute a .jar file using shell script

I want to execute a jar file of DOMO CLI from a shell script. The jar file itself has some functions which I want to call after I call the main jar file. The problem which I am facing is that after it executes the jar file, I am not able to pass the additional commands to execute inside that jar through a shell script. It just stops after calling jar and doesn't take further commands. Can anyone please help? Below is the code I am calling from a shell script.

java -jar XX.jar

The commands are as below which follow the above jar. So once we enter into the above jar we have to execute the below commands one after the other. I am not sure how to achieve this through a shell script.

connect -s X.domo.com -t Ysssss

upload-dataset -a -i dhdhdhdh -f /prehdfs/dev/comres/herm/data/yyyy.csv

Upvotes: 1

Views: 5629

Answers (2)

ARobertson
ARobertson

Reputation: 2897

If you can reference a file in your use case, you could put your commands in a file.

File: list_my_datasets.domo

connect -t ... -s ...
list-dataset
quit

then run the command:

java -jar domoUtil.jar -script list_my_datasets.domo > datasets

I wanted the data from it so I piped to a file (where I had to grep what I wanted), but you would omit that I believe, unless it has some output you'd want to check. I haven't tested with the upload command, but I would hope any commands substituted or added to the example work similarly.

Domo docs on scripting

Upvotes: 0

Amit
Amit

Reputation: 13

Did you try using pipes and inputs. When you execute above it runs it under a child shell.

You may try below format if not tried already

$ (echo "connect -s X.domo.com -t Ysssss" && cat) | java -jar XX.jar

Upvotes: 1

Related Questions