0

I'm new to ubuntu and logged in as user abc (shows Desktop)

I need to call the following app when I'm logged in as user abc: /home/xyz/zzzapp/zzz -param1 -param2

user abc and xyz are members of sudo.

I'd like to have a .desktop shortcut on abc that logs in as user xyz opens a terminal and calls the app zzz -param1 -param2

If terminal asks me for password it's ok for me

how can I do this?

  • which desktop do you have on your Ubuntu? GNOME, MATE, ... ? – damadam Jun 25 '18 at 13:06
  • which desktop - I installed ubuntu 18.04 LTS - the default one – ssssstut Jun 25 '18 at 15:26
1

The ~/.local/share/applications/zzz.desktop file will look like:

[Desktop Entry]
Name=Run zzz as xyz
Exec=bash -c 'su -c "/home/xyz/zzzapp/zzz -param1 -param2" xyz; read -p "Hit Enter to close terminal:"'
Terminal=true
Type=Application

Why do you need a desktop icon? I would recommend this:

  1. add this function to your ~/.bashrc

    zzz() { su -c '~/zzzapp/zzz -param1 "$(bash get_ggggg.sh)"' -l xyz; }
    
  2. when you want to run it, open a gnome-terminal and enter the command zzz

  • thank you, works great! However I just found out that param 2 is actually something like this: zzz -param1 bash get_ggggg.sh --> bash: get_gggg.sh: no such file or directory Further is it possible to just start a command shell in the home directory? e.g.: ckick on icon, login - command shell for xyz starts where I can input custom commands – ssssstut Jun 25 '18 at 18:46
  • when I put the bash get_ggg.sh into double single quotes instead of one single quote: error diappears on calling however command error: too many arguments as reply from zzz app – ssssstut Jun 25 '18 at 18:57
  • "double single quotes" are useless. See update in my answer – glenn jackman Jun 25 '18 at 19:09
  • function: thanks for the great idea! However when I start my app zzz reports: Error: (Invalid_argument "Utils.parse_addr_port: IPv6 addresses must be bracketed") ----> note: start it normally in command shell works. Any suggestions? – ssssstut Jun 25 '18 at 20:54
  • No. Insufficient data. – glenn jackman Jun 25 '18 at 20:57

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.