1

I have one jar which i need to run on startup and no matter whatever user is logged in and that need to take that user name automatcally here this code can take user name

echo $(logname)

and this command i need to run on start up.

java -jar /home/(username)/VISDashboard2014/VISDashboard.jar

so now how can i take dynamically username in to this command.?

  • 1
    You can use $HOME or $USER Environment Variables. In which $USER provide <username> and $HOME provide /home/$USER path. (You should replace (username) with $(logname) or $USER) – Pandya Jul 1 '14 at 12:50
  • can u post simple command then?? – Kishan Bheemajiyani Jul 1 '14 at 13:50
  • Yes Dude its working u can post it as ans i will accept it :) – Kishan Bheemajiyani Jul 1 '14 at 13:53
  • $USER i am using put it will accept. – Kishan Bheemajiyani Jul 1 '14 at 14:04
1

You can use following conmand:

In which $USER is environment variable which gives username

java -jar /home/$USER/VISDashboard2014/VISDashboard.jar
| improve this answer | |
2

Use the following:

java -jar /home/$USER/VISDashboard2014/VISDashboard.jar
| improve this answer | |
1
java -jar /home/$(logname)/VISDashboard2014/VISDashboard.jar 

should work.

| improve this answer | |
1

You need to make a desktop entry (Google for format) with the line Exec=java -jar $HOME/VISDashboard2014/VISDashboard.jar.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.