Scripting problem.

gregaryb

New Member
Joined
Nov 5, 2023
Messages
24
Reaction score
4
Credits
301
I have a file named sudoexec located in \usr\local\bin

It contains the following:
Code:
#!/bin/bash

sudo -S $1

It has x property set:
gregary@Veriton-X4630G:/usr/local/bin$ dir -l
total 28
-rwxr-xr-x 1 root root 7692 Nov 23 2021 apt
-rwxr-xr-x 1 root root 536 Apr 26 2022 gnome-help
-rwxr-xr-x 1 root root 196 Feb 7 2019 highlight-mint
-rwxr-xr-x 1 root root 964 May 15 2019 search
-rwxrwxrwx 1 gregary gregary 25 Nov 6 03:18 sudoexec
-rwxr-xr-x 1 root root 553 Apr 26 2022 yelp
So how do I create a desktop file to run this script with any parameter?

I am trying t do it like you do with windows batch files. Where you, for example, have a backup batch file which runs a data back up on the disk drives specified as parameters.
So I want to do this effectively...
sudoexec "nemo %U"
sudoexec "VNC"
Etc.
Run any program in god mode simply by double licking my various .desktop short cuts, without have to create a seperate script file for each program.
But unfortunately double clicking on my .desktop files will not run the program - nothing happens.
 
Last edited:


G'day @gregaryb and welcome to linux.org :)

I'll be moving this to https://www.linux.org/forums/command-line.145/ , where scripting inquiries are answered.

However, I can tell you a couple of things:
  1. You have written in a variable $1 but you simply typed sudoexec without passing a name/command to be used in place of $1, that is, you have no argument, hence the output you get.
  2. With the executable aspect, I would be removing the 2nd and 3rd w's for security purposes, so that it will look like the other scripts in your /usr/local/bin. You can do that with the following
    Code:
    sudo chmod 755 /usr/local/bin/sudoexec
    so it will look as follows
-rwxr-xr-x

In a few hours, some scripting experts will likely pass through.

Good luck and have fun with your scripting.

Chris Turner
wizardfromoz
 

Members online


Latest posts

Top