bash script exec : with sudo ?

Forum Forums General Tips and Tricks bash script exec : with sudo ?

  • This topic has 4 replies, 3 voices, and was last updated Nov 14-6:50 pm by kouroukinos77.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #44464
    Member
    kouroukinos77

      Hi I try to write an bash executable script for launch two command, but I need sudo to execute :

      #!/bin/bash
      
      sudo modprobe snd_pcm_oss snd_mixer oss
      exec zsnes
      

      In command line it work, he said me enter the password for root…
      But in thunar or pcmanfm I don’t have the message for enter root password, and the modprobe don’t work, and I don’t have sound in zsnes, I’m try when I click on this script to launche zsnes with that command “modprobe” … but how to do that ? Thank you for the help !

      $ uname -r
      4.9.212-antix.1-amd64-smp
      Mon retour de inxi -Fxz : https://pastebin.com/kqRMrRZZ
      my xmpp : weerbor@jabber.fr

      #44487
      Member
      sybok
        Helpful
        Up
        0
        ::

        If you want to run it not from terminal, try to open terminal (e.g. roxterm, lxterminal) and execute the command (-e) of your script.
        This will always open pop-up window

        #!/bin/bash
        roxterm -e "<command from your script> && exit 0"

        The && exit 0 ensures the pop-up terminal closes if the execution has been successful but it stays open if any problems encountered.
        This is useful for debugging.

        • This reply was modified 2 years, 6 months ago by sybok. Reason: Word selection improved
        #44493
        Member
        Xecure
          Helpful
          Up
          0
          ::
          #!/bin/bash
          
          sudo modprobe snd_pcm_oss snd_mixer oss
          exec zsnes

          Change this, following sybok’s advice:

          #!/bin/bash
          
          x-terminal-emulator -e "sudo modprobe snd_pcm_oss snd_mixer oss && exit 0"
          zsnes &

          antiX Live system enthusiast.
          General Live Boot Parameters for antiX.

          #44499
          Member
          sybok
            Helpful
            Up
            0
            ::

            Ah, I forgot to/didn’t put the zsnes after the && exit 0.
            Thanks for correcting, Xecure.

            • This reply was modified 2 years, 6 months ago by sybok.
            #44972
            Member
            kouroukinos77
              Helpful
              Up
              0
              ::

              Oh ok ! so,

              on Icewm, I need to create on my Desktop, a short icon, for launch that… Or in the Icewm menu, but I don’t know how to do that. It’s same for my HMA cli Launcher (VPN), and Icecat. Thank you !

              oh sorry, I solved this problem like this :

              In my .icewm menu , I add this line :

              prog HMA ! bash /home/pikaburk/hma-vpn.sh /home/pikaburk/hma-vpn.sh /home/pikaburk/hma-vpn.sh
              prog Icecat ! bash /home/pikaburk/icecat.bash /home/pikaburk/icecat.bash /home/pikaburk/icecat.bash

              (just for add apulse for icecat and the sound, and hma-vpn launch in roxterm), but the command for launch directly hma with london vpn server don’t work (the sudo hma-linux/hma-openvpn.sh -p udp London with the bash script that I download on the official website); but it’s not a problem and the subject) and I create a ticket for that on hma website. Thank you !

              and with your bash learning, It work good now. Thank for the studies.

              • This reply was modified 2 years, 5 months ago by kouroukinos77.
              • This reply was modified 2 years, 5 months ago by kouroukinos77.
              • This reply was modified 2 years, 5 months ago by kouroukinos77.

              $ uname -r
              4.9.212-antix.1-amd64-smp
              Mon retour de inxi -Fxz : https://pastebin.com/kqRMrRZZ
              my xmpp : weerbor@jabber.fr

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.