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.?

4
  • 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, 2014 at 12:50
  • can u post simple command then?? Jul 1, 2014 at 13:50
  • Yes Dude its working u can post it as ans i will accept it :) Jul 1, 2014 at 13:53
  • $USER i am using put it will accept. Jul 1, 2014 at 14:04

4 Answers 4

2

Use the following:

java -jar /home/$USER/VISDashboard2014/VISDashboard.jar
1

You can use following conmand:

In which $USER is environment variable which gives username

java -jar /home/$USER/VISDashboard2014/VISDashboard.jar
0
1
java -jar /home/$(logname)/VISDashboard2014/VISDashboard.jar 

should work.

2
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .