Question

when i double click on an executable file, it wont run after i click RUN. i have tried it with a couple of .sh files and some downloaded software, does anyone know why?

a particular .sh file i need to run is a zenity menu. When i try in terminal it just says

sh: Can't open TaskC.sh

thats after i use

sh TaskC.sh

in the file i have used the properties to make it executable and used

chmod 755 TaskC.sh
  1. Does anyone know how i can run it without the terminal?
  2. Anyone know how i can get the .sh to run in the terminal?

my code just incase thats the problem

#!/bin/bash
#GUI for TaskB menu
chmod 755 TaskC.sh
    temp='mktemp -t temp.XXXXXX'
    temp2='mktemp -t temp2.XXXXX'

function software {
sudo get-apt install gparted gnome-desk-utility
zenity --text-info --title "Install Software" --filename=$temp
--width 750 --height 10}

function create {
touch > Desktop/CET103Demo.txt
zenity --text-info --Title "Create CET103Demo.txt" --filename=$temp
--width 300 --height 500}

function delete {
rm Desktop/CET103Demo.txt
zenity --text-info --title "Remove CET103Demo.txt" --filename=$temp
--width 300 --height 500}

function search {
grep -H -r "BASH" /home/mintuser/.profile
zenity --text-info --Title "Search BASH" --filename=$temp
--width 300 --height 500}

while [ 1 ]
do

zenity --list --radiolist --title "TaskC Menu" --column "Select" --column "Menu     Selection"
FALSE "Install Software" FALSE "Create file" FALSE "Remove File" FALSE "Search BASH"   False  "Exit"   > $temp2
if [ $? -eq 1 ]
then
break fi
    selection ='cat $temp2'
    case $selection in
    "Install Software")
        software;;
    "Create File")
        create;;
    "Remove File")
        delete;;
    "Search BASH")
        search;;
    Exit)
break ;; *)
zenity --info "Sorry, invalid selection" esac
done $

many thanks

Was it helpful?

Solution

Try with ./TaskC.sh

You have to be in the same directory than the script, of course. If you want to execute it from anywhere, you need to add it to your PATH (see KevinDTimm's answer)

OTHER TIPS

To fix the problem in your terminal window:

The problem is that your PATH is incorrect, you have to include the current directory

first fix is to run sh ./TaskC.sh - this has to be done each time you run something in the current directory

second is to set your PATH like export PATH=$PATH:. - this will fix it for the current invocation of your shell. Add that line to .bashrc for it to be set every time you log in

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top