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?

Bruni
  • 10,542
ssssstut
  • 667

1 Answers1

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

glenn jackman
  • 17,900
  • 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
  • Is it possible to just start a command shell with the other user in the home directory? e.g.: abc's desktop: ckick on icon, login - command shell for xyz starts where I can input custom commands – ssssstut Jun 26 '18 at 06:51
  • su -l xyz does that – glenn jackman Jun 26 '18 at 09:53
  • Thank you very much! Side note -l for login not minus one worked: 'Exec=bash -c 'su -l xyz' ' – ssssstut Jun 26 '18 at 10:44
  • Is there any chance to show a different / additional text on the terminal windows? Curently only "Terminal" is shown. Better to distinguish would be "Terminal myXYZtext" – ssssstut Jun 26 '18 at 10:53
  • terminal title: found this, but it did not work: https://askubuntu.com/questions/777833/can-no-longer-set-terminal-title-in-ubuntu-16-gnome-terminal/777836 - I can set a title in an open cmd-shell however it doesn't work like this: ' Exec=bash -c 'su -c "/home/xyz/zzzapp/zzz -param1 -param2" xyz; set-title "hello"; read -p "Hit Enter to close terminal:"' ' - any suggestions? – ssssstut Jun 26 '18 at 12:49
  • The perfect solution would be if the [Desktop Entry] Name=myTitle could be displayed in the title. Does anyone know if this is possible? – ssssstut Jun 26 '18 at 13:17
  • terminal-title: resolved here: https://askubuntu.com/questions/1049970/how-to-pass-a-teminal-title-to-a-terminal-opend-via-desktop-shortcut-desktop – ssssstut Jun 26 '18 at 21:44