How do I run .sh files?

1

Open your terminal and navigate to the directory where your .sh file is located.

So suppose your file is under the Desktop/shell_scripts directory you would do something like this.

tasdik@Acer:~$ tasdik@Acer:~$ cd Desktop/shell_scripts/ tasdik@Acer:~/Desktop/shell_scripts$

Now see the permissions for you files inside that directory

tasdik@Acer:~/Desktop/shell_scripts$ ll total 8 drwxrwxr-x 2 tasdik tasdik 4096 Oct 18 12:32 ./ drwxr-xr-x 8 tasdik tasdik 4096 Oct 18 12:28 ../ -rw-rw-r-- 1 tasdik tasdik 0 Oct 18 12:32 bar.txt -rw-rw-r-- 1 tasdik tasdik 0 Oct 18 12:32 foo.txt -rw-rw-r-- 1 tasdik tasdik 0 Oct 18 12:29 hello .sh tasdik@Acer:~/Desktop/shell_scripts$

Make your bash script executable

As we can see, our .sh file only has read and write permissions for the

tasdik@Acer:~/Desktop/shell_scripts$ chmod ug+x hello. sh tasdik@Acer:~/Desktop/shell_scripts$

The above command makes the shell script executable for both the user (u) and group...

0 0
2
Hi. I know that if I want to use .sh files, I need make it executable and to execute
"./shfile.sh"
command.

But my question is as follows : I don't know why, but when I click on any .sh file, a program launches with "Wine Windows Program Loader" name and I see wine's icon jumping for a few seconds near my cursor. Then it disappears. I know Wine shouldn't be used to open .sh files, I don't know why it's so. I can for example use Kwrite to open it and even make it default program for opening, but what when I want to execute it? I mean, what command should I type in "Open in.." window?

I prefer to use Yakuake, so it would be great if you could tell me the command for yakuake, not...

0 0
3

2.1.1. Writing and naming

A shell script is a sequence of commands for which you have a repeated use. This sequence is typically executed by entering the name of the script on the command line. Alternatively, you can use scripts to automate tasks using the cron facility. Another use for scripts is in the UNIX boot and shutdown procedure, where operation of daemons and services are defined in init scripts.

To create a shell script, open a new empty file in your editor. Any text editor will do: vim, emacs, gedit, dtpad et cetera are all valid. You might want to chose a more advanced editor like vim or emacs, however, because these can be configured to recognize shell and Bash syntax and can be a great help in preventing those errors that beginners frequently make, such as forgetting brackets and semi-colons.

Put UNIX commands in the new empty file, like you would enter them on the command line. As discussed in the previous chapter (see Section 1.3), commands...

0 0
4

Windows 10’s Anniversary Update offers a big new feature for developers: A full, Ubuntu-based Bash shell that can run Linux software directly on Windows. This is made possible by the new “Windows Subsystem for Linux” Microsoft is adding to Windows 10.

What You Need to Know About Windows 10’s Bash Shell

This isn’t a virtual machine, a container, or Linux software compiled for Windows (like Cygwin). Instead, Windows 10 gains a Windows Subsystem for Linux, which is based on Microsoft’s abandoned Project Astoria work for running Android apps on Windows.

Think of it as the opposite of Wine. While Wine allows you to run Windows applications directly on Linux, the Windows Subsystem for Linux allows you to run Linux applications directly on Windows.

Microsoft has worked with Canonical to offer a full Ubuntu-based Bash shell that runs atop this subsystem. Technically, this isn’t Linux at all. Linux is the underlying operating system kernel, and that...

0 0
5
how to run .pl script file

location: linuxquestions.com - date: April 8, 2009
hai , I have downloaded a tar.gz package in that it says to run the config.pl script before installing that software,but i don't know to run that script ... so far i have tried the command pl config.pl but it GNOME terminal shows that the commmand not found message thanks in advance

[SOLVED] Bash script: How to get script file name commands are executed from?

location: ubuntuforums.com - date: August 7, 2008
Hi, in Ubuntu 8.04 I have several bash scripts. I would like to write to log file script_file_name from witch command is executed from. Sample: --- script file: 1.sh --- echo "1.sh" >> mylog.log --- script file: 2.sh --- echo "2.sh" >> mylog.log Is there any command I could write: echo "$get_name_of_this_scrip_file Now if file get renamed I need to manually rename echo command in script file. I would like to avoid this renaming. Regards, Abcuser
...

0 0
6


that script dose NOT install firefox or seamonkey

it never did and never will

what it dose is LAUNCH the prebuilt program
WITH non default settings for your system
using mozillas settings and NOT yours

Quote:

that normally means that you are NOT in the folder that firefox or seamonkey is in

as in you did not open the terminal in that folder or you did not " cd " to that folder

Quote:

see the above

as in were you in the folder FOR THAT PRINTER SOFTWARE

if this is firefox
them Mint ALREADY has it installed
it is installed by DEFAULT
now it might be called "lceweasel"

"lceweasel" is the 100% OPEN SOURCE rebranding of firefox with the COPYRIGHTED graphics removed

1 members found this post helpful.

Thanks for your help jlinkels,

My bad, there was no space. I actually used the command ./run-mozilla.sh
Error: run-mozilla.sh: Cannot...

0 0
7

Hi..,

Since the code snippet you've posted is out of a JSP page, I'm not exactly clear as to which platform you are refering to : the server platform [where the webapp is running], or the client platform [from where the client is accessing this weapp].

Anyhow, the generic solution is to identify the OS type, and fire your commands accordingly. Java has certain system level properties set, and one among them is the "os.name" property. So what you can do is:

String osName = System.getProperty("os.name");

if(osName.equals(// check for windows))
{
Runtime.getRuntime().exec(batch_file);
}
else if(osName.equals(// check for linux))
{
Runtime.getRuntime().exec(sh_file);
}
else
{
System.out.println("unsupported OS");
}

Be noted that the sh extension can be understood by other Unix versions too other than Linux... So, code...

0 0
8

application for shell gas card

I am trying to get the max version number from a directory where i have several versions of one program shell jokes

for example if output of ls is

something01_1.sh something02_0.1.2.sh something02_0.1.sh something02_1.1.sh something02_1.2.sh something02_2.0.sh something02_2.1.sh something02_2.3.sh something02_3.1.2.sh something.sh

I am getting the max version number with the following -

ls somedir | grep some_prefix | cut -d '_' -f2 | sort -t '.' -k1 -r | head -n 1

Now if at the same time i want to check it with the version number which i already have in the system, whats the best way to do it...

in bash i got this working (if 2.5 is the current version)

(ls somedir | grep some_prefix | cut -d '_' -f2; echo 2.5) | sort -t '.' -k1 -r | head -n 1

is there any other correct way to do it?

EDIT: In the above example some_prefix is something02.

EDIT: Actual Problem here is

(ls smthing; echo more) |...
0 0
9

Prerequisite

Before you can run the .sh file, you need to make it executable:

Right-click on the file Select Properties Select Permissions Select Allow executing file as a program

Warning

Make sure you trust the source where you got the file from. It could be a virus.

The very simple way

Double-click on the file Click run in terminal

This has problem. The terminal will close immediately and you will not be able to see the output.

The simple way

Open Applications -> Accessories -> Terminal Drag and drop the .sh file into the terminal and press Enter

The way professionals do it

Open Applications -> Accessories -> Terminal

Find where the .sh file

Use the ls and cd commands ls will list the files and folders in the current folder. Give it a try: type "ls" and press Enter. Once you see the folder that you want to go in to, run cd, followed by a space, followed by a folder name If you when into a folder...
0 0
10

copy the file to the desktop (for convenience)

Right click on the file and select properties

Under permission tab check allow executing file as program

double click on the file and chose run in terminal if it is not a gui program)

By default the file manager may not show that option and open the file in gedit instead. In that case change the preference of the file manager at: Edit-> Preferences -> Behaviour to "ask each time" or right away to "run executables"

Command line

cd /path/to/file chmod +x filename.sh ./filename.sh

Comment below if it wont work :)

If it still won't work, despite having allow executing file as a program ticked, when you double click on the .sh file, and it launches gedit, navigate to the folder with the script.

Once you are in the correct current folder for the script, you can run the script like this:

sudo ./filename.sh

If that doesn't work you may...

0 0
11

Occasionally, some applications and games (eg. some from the Humble Indie Bundle) have .run installers. Before installing using these, check to see if:

it is available from the Software Centre it is available as a .deb file, which will open in the Software Center

You can install .run files from the graphical interface, but using a terminal is more likely to give you useful feedback. To install a .run file you need to:

make it executable. execute it

This is because .run files are just executable programs that do some unknown magic to install the program. This is similar to what .exe installers do on Windows and is different to the normal methods (at best, using the Software Centre, at worst using .deb files) in which applications are installed in a standard way and can be easily removed.

Graphical Method

Right click on the file in the file manager and click 'Properties'. Click the 'Permissions' tab and tick the box that says 'Allow executing file as...
0 0
12

Did your computer fail to open a SH file? We explain what SH files are and recommend software that we know can open or convert your SH files.

What is a SH file?

Files that contain the .sh file extension are self-extracting archive files. The SH file archive contains selected files and a shell script along with instructions on how to extract the contents of the SH file archive.

The SH file format is commonly used for Unix shell files and are created by the Unix shar utility program. These files are typically used for scripts that are meant to be run on the Unix command prompt. SH files can typically only be used on computers that are run on the Unix operating system, although systems similar to Unix may also use this file...

0 0
13

To avoid the hassle (and for many people scariness and intimidation) of editing the registry, you could use the free, excellent, and non-invasive repair utility which actually accomplishes any good (versus many other crapware), tweaking.com Windows Repair.

Specifically: install it, skip ahead to the "Repairs" tab, click "Open Repairs," and put a checkmark in "04 Register System Files," then click the "Start Repairs" button.

The user interface of that program has changed over time, so in the future, anyone doing this may need to explore the program to find this option.

I would hazard a guess that a lot of other problems exist on your Boss' computer, so that he may want to run all the program's repairs, which can take hours, depending.

Note: I am not affiliated with tweaking.com; I'm just a big fan of the program. Skilled use of it has saved my computer's operating system or solved stubborn problems multiple...

0 0
14
I’

ve downloaded software for Linux or Unix-like system from the Internet. There is a file called install.sh. How do I run an .sh file to install the software?


The .sh file is nothing but the shell script to install given application or to perform other tasks under Linux and UNIX like operating systems. The easiest way to run .sh shell script in Linux or UNIX is to type the following commands. Open the terminal (your shell prompt) and type the command.

You can run the .sh file using the following syntax

Set execute permission on your script:
chmod +x script-name-here.sh To run your script, enter:
./script-name-here.sh
OR
sh script-name-here.sh
OR
bash script-name-here.sh

Syntax

The syntax is:

OR

.sh File As Root User

Some time you need root access to install application; without root, you won’t have the necessary permissions to install application or make system level modifications....

0 0
15

To run a non-executable sh script, use:

sh myscript

To run a non-executable bash script, use:

bash myscript

To start an executable (which is any file with executable permission); you just specify it by its path:

/foo/bar /bin/bar ./bar

To make a script executable, give it the necessary permission:

chmod +x bar ./bar

When a file is executable, the kernel is responsible for figuring out how to execte it. For non-binaries, this is done by looking at the first line of the file. It should contain a hashbang:

#! /usr/bin/env bash

The hashbang tells the kernel what program to run (in this case the command /usr/bin/env is ran with the argument bash). Then, the script is passed to the program (as second argument) along with all the arguments you gave the script as subsequent arguments.

That means every script that is executable should have a hashbang. If it doesn't, you're not telling the kernel what it is, and therefore the kernel doesn't know what...

0 0
16

Hello Hurtboss,

Try renaming the bat file to run.sh, as others have suggested.

Then open run.sh in a text editor and remove the lines:

@ECHO OFF

title jvm

echo jvm

echo Newest client running

And add this line:

#!/bin/sh

This line makes it work like a bat file does under windows.

Next change the line:

JAVA -Xmx500m EGUI

so that the word Java is all lowercase:

java -Xmx500m EGUI

The reason for this is that under Unix (which Linux is based off of) most applications have lower names.

So you should have something similar to:

#!/bin/sh
java -Xmx500m EGUI

Now, if you are using a terminal, run

chmod u+x run.sh

This makes it executable, so that you can run it. (it sets the X bit that Steve Tompkins-MacQueen mentioned.) This is unlike Windows, where anything with a .exe extension will be launched as a an executable. This goes into a bit more depth if...

0 0
17

When you run any script by passing the filename to the script interpreter program, you are running the interpreter program with the script as an argument passed into it. For example this would look like the process 'sh' with the argument 'filename.sh'. The sh interpreter is opening the file.

On the other hand if you run the script itself, the system calls out to the interpreter program specified and feeds in the scripts contents. In this case the process looks like 'filename.sh' with no arguments.

You should make sure you have a bang line:

#!/bin/bash # bash script here

A bang line is the very first line in the script and starts with the same two characters #!, these are what the system reads when it tries to execute the script and then the system passes the the script to the program immediately after. Note that this line isn't anything to do with bash and works just as well for python and perl, even though they're very different languages. You would use...

0 0
18

I am trying to write a sh script that will run when one of my downloads is completed.

It should look for a specific filename on ~/Downloads and move it to a different dir depending on the filename.

I.e. I have downloaded the last episode of Glee, the filename is:

glee_some_trash_files_always_have.mkv

It should be moved to

~/TVshows/Glee/

This is what I was able to do:

#!/bin/bash if filename in ~/Downoads; then result= if filename = *glee*; then result= mv $filename ~/TVshows/Glee/ else if filename = *pokemon*; then result= mv $filename ~/TVshows/pokemon/ endif done

Is my approach correct? Please note I am very new to sh.

Thanks in advance.

###############################################################################

Edit: Here is my script, I hope someone else could find it useful:

#!/bin/bash cd "$HOME/Downloads" # for filename in *; do find . -type f | while IFS= read filename; do # Look for files in all...
0 0