How to make .SH Files Run in Terminal?

Issues and / or general discussion relating to Puppy

Moderator: Forum moderators

Post Reply
sonny
Posts: 725
Joined: Mon Feb 15, 2021 4:50 pm
Has thanked: 486 times
Been thanked: 173 times

How to make .SH Files Run in Terminal?

Post by sonny »

Hello,
What is the script/command that executes an .sh file to run or open inside the Terminal window?
Very much appreciated!

User avatar
Jafadmin
Posts: 385
Joined: Tue Aug 04, 2020 4:51 pm
Has thanked: 68 times
Been thanked: 85 times

Re: How to Make .SH Files Run in Terminal

Post by Jafadmin »

Try this:

Code: Select all

'/usr/bin/urxvt -e' '/path/to/script.sh'

-e command [arguments]
Run the command with its command-line arguments in the urxvt window; also sets the window title and icon name to be the basename of the program being executed if neither -title (-T) nor -n are given on the command line. If this option is used, it must be the last on the command-line. If there is no -e option then the default is to run the program specified by the SHELL environment variable or, failing that, sh(1).

Please note that you must specify a program with arguments. If you want to run shell commands, you have to specify the shell, like this:

urxvt -e sh -c "shell commands"

ozsouth
Posts: 1559
Joined: Sun Jul 12, 2020 2:38 am
Location: S.E. Australia
Has thanked: 241 times
Been thanked: 692 times

Re: How to Make .SH Files Run in Terminal

Post by ozsouth »

@sonny - assuming the script is executable, prepend it with ./ in the terminal. i.e. ./myscript.sh & press Enter. To be sure script is executable, in a terminal run chmod 755 (whatever your script is).

EDIT: Jafadmin posted as I was typing. That works too. EDIT2: mikewalsh posted as I edited - that works too.

Last edited by ozsouth on Thu May 13, 2021 12:18 am, edited 2 times in total.
User avatar
mikewalsh
Moderator
Posts: 6149
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 788 times
Been thanked: 1976 times

Re: How to Make .SH Files Run in Terminal

Post by mikewalsh »

@sonny :-

Two ways you can do it. Right-click in an open bit of the ROX window beside your script. Then, Window->Terminal here.

When the terminal opens, just type

Code: Select all

./name-of-your-script.sh

.....and hit 'Enter'.

Or - even simpler! - rt-clk on the script itself->Run in Terminal. Both should do what you want.

Hope that helps.

---------------------------

Three of us answering at the same time..! :lol: Jafa's suggestion is, of course, the "geeky", technically correct way to do it, which would work for ANY Linux distro. You'll find much of his advice is OS-agnostic. This pre-supposes that you're running the command from one shell, with the express intention of then actually running the script itself within another shell.

My own suggestions are partly Puppy-specific, though the use of "./" along with running the terminal from the file-manager window would also work anywhere. As Oz has suggested, too. Like so much in Linux, there are literally dozens of ways of achieving precisely the same outcome... :)

(Strictly speaking, there's no really "right" or "wrong" way of doing it, although the 'old guard' would have you believe otherwise. This stems from the fact that many of them started with Linux when it was still relatively new - some even migrating from Unix itself - and everybody was really conscious of doing things "properly" in those days, mainly so the rest of the community would accept them....)

Mike. ;)

User avatar
Jafadmin
Posts: 385
Joined: Tue Aug 04, 2020 4:51 pm
Has thanked: 68 times
Been thanked: 85 times

Re: How to make .SH Files Run in Terminal?

Post by Jafadmin »

My response was intended to create a desktop "launcher" or icon that will start a console based app in a console window. Consider a desktop shortcut called "XApps" that ran:

Code: Select all

'/usr/bin/urxvt -e' 'ps -eal | grep tty1'

That will run 'ps' and show all apps running under your X session.

User avatar
April
Posts: 493
Joined: Tue Dec 29, 2020 9:06 pm
Has thanked: 57 times
Been thanked: 28 times

Re: How to make .SH Files Run in Terminal?

Post by April »

Thought to try that and got

Code: Select all

root# '/usr/bin/urxvt -e' 'ps -eal | grep tty1'
bash: /usr/bin/urxvt -e: No such file or directory
root#   

xenialpup64-7.5
/usr/bin/urxvt is there and the balance runs. So I was just trying to understand what I did wrong?

Code: Select all

root# '/usr/bin/urxvt -e' 'ps -eal | grep tty1'
bash: /usr/bin/urxvt -e: No such file or directory
root# ps -eal | grep tty1
4 S     0  6568     1  0  80   0 -  3373 -      tty1     00:00:00 sh
0 S     0  6684  6568  0  80   0 -  2806 -      tty1     00:00:00 xwin
4 S     0  6786  6684  0  80   0 -  4016 -      tty1     00:00:00 xinit
4 S     0  6854  6786  0  80   0 - 42383 -      tty1     00:00:06 jwm
5 S     0  6987     1  0  80   0 - 48906 -      tty1     00:00:12 ROX-Filer
0 S     0  6988  6854  0  80   0 -  2388 -      tty1     00:00:00 pup_event_front
1 S     0  7078     1  0  80   0 -  2804 -      tty1     00:00:00 delayedrun
0 S     0  7080  7078  0  80   0 - 30123 SyS_po tty1     00:00:00 yad
4 S     0  7268     1  7  80   0 - 325207 -     tty1     00:04:15 opera.bin
0 S     0  7517  6987  0  80   0 - 61144 -      tty1     00:00:04 clipit
0 S     0  7530  6987  0  80   0 - 78171 SyS_po tty1     00:00:00 dunst
1 S     0  7549     1  0  80   0 -  9319 core_s tty1     00:00:00 dbus-launch
0 S     0  7551  6987  0  80   0 - 41886 -      tty1     00:00:00 freememapplet_t
0 S     0  7554  6987  0  80   0 - 42517 -      tty1     00:00:03 netmon_wce
0 S     0  7568  

The Australian State Governments have all enacted laws to steal your assets on your death. All legal paperwork is binned and all assets seized on one disgruntled child's complaint.Move them well before you die or go into a home.

dancytron
Posts: 721
Joined: Fri Dec 13, 2019 6:26 pm
Has thanked: 518 times
Been thanked: 215 times

Re: How to make .SH Files Run in Terminal?

Post by dancytron »

I cribbed it off of Fredx, but its very handy for "do you really want to do that" scripts.

Code: Select all

#!/bin/bash

xterm -T "Remove Chrome Profiles and other stuff" -si -sb -fg white -bg SkyBlue4 -geometry 80x22 -e /usr/local/bin/RemoveAllChromeSettings.sh

runs

Code: Select all

#!/bin/sh

# Deletes all Chrome user settings and caches .  Mostly for prior to remaster.  Use caution.
#8-15-19 added /root/.mozilla and /home/puppy/.mozilla to pick up stray firefox stuff
#add /root/.thunderbird which gets created when you click a mailto: link without thunderbird running
#add entries for nvidia cache in puppy and more mozilla misplaced firefox garbage when you open html file from 
#file manager 12-27-19

echo "CAUTION"
echo "This script deletes all Chrome user settings, misplaced Firefox and Thunderbird settings, and their cache files for all users."
echo "This is mainly useful for remastering."
echo "If that is not what you want to do, press Control-C now."
read -sp "Press ENTER to continue if you are sure"
clear
echo
set -x  #echo on
rm -r /home/cat/.config/google-chrome ; rm -r /home/cat/.cache/google-chrome ; rm -r /home/cat/chrome ; rm -r /home/puppy/chrome ; rm -r /root/.config/google-chrome ; rm -r /root/chrome ; rm -r /home/puppy/.config/google-chrome ; rm -r /home/puppy/.cache/google-chrome ; rm -r /root/.cache/google-chrome ; rm -r /live/image/ChromeSettings/google-chrome ; rm -r /root/.mozilla ; rm -r /home/puppy/.mozilla ; rm -r /root/.thunderbird ; rm -r /root/.cache/mozilla/firefox ; rm -r /home/puppy/.nv/GLCache
set +x  #echo off
read -sp "Press ENTER to close"
williams2
Posts: 1062
Joined: Sat Jul 25, 2020 5:45 pm
Been thanked: 305 times

Re: How to make .SH Files Run in Terminal?

Post by williams2 »

Code: Select all

urxvt -e top

Code: Select all

urxvt -e htop

Code: Select all

urxvt -hold -e ps

Code: Select all

urxvt -hold -e sh -c "ps -eal | grep tty1"

press <enter> key to close window:

Code: Select all

urxvt -e sh -c "ps -eal | grep tty1 ;read"
Post Reply

Return to “Users”