1

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
9
  • 1
    java -jar XX.jar & will start the java process and run it in the background (so your other commands will then execute). Commented Jul 24, 2019 at 4:56
  • @ElliottFrisch it does start the java process but it doesn't run the commands after that. It is showing the blank screen thereafter. I have executed like below: java -jar XX.jar & connect -s X.domo.com -t Ysssss Commented Jul 24, 2019 at 4:59
  • Are those lines are meant to be supplied on standard in to the java process? If so, take a look at expect. Commented Jul 24, 2019 at 5:14
  • @ElliottFrisch : I don't see any & in the post! Commented Jul 24, 2019 at 6:51
  • @yogesh: In what way does the Java program expect the additional input? By command line, via stdin, via some configuration file .... ? Commented Jul 24, 2019 at 6:55

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

3 Comments

The code you provided works but if I try to run the another code together, it fails to execute. I am executing code like this: (echo "connect -s X.domo.com -t Ysssss" && upload-dataset -a -i dhdhdhdh -f /prehdfs/dev/comres/herm/data/yyyy.csv && cat) | java -jar XX.jar .... It gives error "No such file or directory" on /prehdfs/dev/comres/herm/data/yyyy.csv. Any suggestions?
it is working only to run 1 command, but if more than 1 needs to be run, it is giving error.
What is the output of $ls -alt /prehdfs/dev/comres/herm/data/yyyy.csv
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.