Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sh]

/bin/sh is the POSIX shell. For questions where portability is important. If the question is about .sh files, tag it with `scripts` instead.

4
votes
1answer
37 views

update-alternatives for sh reports bash is used, but I still get dash

I just upgraded to Ubuntu 18.10 from Ubuntu 17.10. I have my box configured to use bash as the default shell rather than the default dash. I've made this change with sudo update-alternatives --...
0
votes
1answer
274 views

Not able to execute script using sh <file_name>

I am Not able to execute script using sh file_name But it's working fine with command : ./filename Rgrds Aditya
3
votes
2answers
129 views

sh script for executing mysql script with entering pass

I'd like to execute a mysql script where the user is asked to enter the password dynamically from the command line, if possible with a message Enter your $root password. However it doesn't work as ...
7
votes
4answers
862 views

Change /bin/sh link temporarily

I have a piece of software that requires /bin/sh to be Bash, but for Ubuntu the default is Dash and I want to keep it the default; I don't want to change it to Bash permanently. Is there a way to ...
1
vote
1answer
50 views

How can I launch portable firefox app as a separate application?

I like to compartmentalize my internet browsing. I use one browser for work related stuff, one browser personal banking and bills, and another browser for general social related stuff like online ...
2
votes
1answer
44 views

Execute a shell script without `./` [duplicate]

I'm learning how to create shell scripts on UNIX for a college class. The textbook says I should just be able to type the filename in my terminal and it should run, but so far I haven't been able to ...
0
votes
1answer
147 views

How to automatically kill a process using script? [duplicate]

How to write a script that kills a java process? From console it looks like root@ubuntu-s-1vcpu-1gb-ams3-01:~# lsof -i tcp:8080 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 9657 ...
1
vote
1answer
53 views

Why cron not executing script?

I create a simply script in /root/test.sh file: #!/bin/bash echo "hello" mkdir newdir next: chmod +x /root/test.sh We can convinced, what test.sh is owned by root: root@ubuntu-s-1vcpu-1gb-ams3-01:...
0
votes
1answer
162 views

Running sh script on Lubuntu on startup

Running lubuntu 18.04 LTS with LXDE So, I need to run a simple SH script inside terminal session on startup after login, but I'm struggling to get it running. I've tried: rc.local trick, /.config/...
4
votes
2answers
839 views

What's the problem with Bashisms? [closed]

With "Bashism" I mean shell syntax which is only understood by the bash shell and not other shells. If you write a script which gets executed only in environments where /bin/bash exists, then I think ...
1
vote
1answer
191 views

Run .sh file in one line command [duplicate]

How to start sh file in one line command ? This is how I normally start sh file in the specific path user@user:~$ cd idea-IC-171.4424.56/bin user@user:~/idea-IC-171.4424.56/bin$ ./idea.sh If I ...
3
votes
1answer
24 views

sh script - question about single line [duplicate]

I have this bash script: #!/bin/sh -eux . ./.env What does the second line do? It seems to be impossible to google such syntax :)
3
votes
1answer
72 views

Is it possible to exclude some files from rm -rf? [duplicate]

I have a directory that I is filled by another user, and I'm tasked with maintaining it. I want to delete all its content except a 2 files with a specific name. Is it possible with rm or should I do ...
0
votes
1answer
80 views

sh install.sh and script errors

I was try to install Parallel Studio on Ubuntu 14.04 and should be install some Sh file. When i used sh install.sh, it gave this error: {trap: SIGTSTP: bad trap Error: Incorrect path to installation ...
-3
votes
2answers
689 views

How to run .sh file by click in Xubuntu? [duplicate]

We should type ./file.sh in terminal to run sh. Is there way to run it as executable file by double click ?
0
votes
1answer
4k views

curl command not executing via shell script in bash

I'm learning shell scripting! For the same I've tried downloading the TCGA genome data using curl on ubuntu (Ubuntu 16.04.3 LTS) terminal. sh. content #!/bin/sh echo /0c8a6022-b770-4a83-bac3-...
0
votes
0answers
38 views

SH script not deleting folders [duplicate]

I have the below script located in my cron.daily folder. When executed, it deletes all appropriate files, but the folders remain. Note, that running script from terminal does the same...folders remain....
0
votes
0answers
55 views

cronjob not executing on reboot

I am trying to make a cronjob that executes on reboot of my machine. The job is a .sh script that is located in the custom dir start. path from home is: Home/start/start.sh The script needs sudo ...
1
vote
0answers
47 views

Launching a script in a new gnome-terminal [duplicate]

I am trying to make a script which is supposed to open a new gnome-terminal and issue a command (launch a jetty server). If I try only : gnome-terminal, a new gnome-terminal is opened. If I try : ...
1
vote
1answer
78 views

Set default printer according to IP

Setup: I use my notebook in two locations. At each location, the computer receives an IP address via DHCP. This IP address depends on the location, but is constant for each location over time. ...
0
votes
0answers
246 views

How to install (or simply run?) vmware's converter from Linux?

I'm looking for specific instructions for this, noting that How do I install a .tar.gz (or .tar.bz2) file? can give general guidance. In other words, what to do with VMware-converter-6.2.0-7348398....
0
votes
2answers
58 views

Exception while running the simple sh script

Below is the simple script, while running the script i am getting the exception like line 10: syntax error: unexpected end of file. please help. #!/bin/sh a=10 b=20 if [ 10 == 20 ] then echo "a is ...
0
votes
1answer
27 views

sed command fail to understand with special chars

Can I know what exactly below command is doing sed -e 's/^OR//. I tried running different forms as below and understood it is replacing characters, but when I add ^ I can not understand the pattern ...
1
vote
1answer
141 views

How to integrate “run as shell script” in right click menu of file manager? [closed]

Now when I want to run a shell script (.sh or .csh file), I need to right click the file manager and click "open terminal here", then type "./xxx.sh" to run the shell script file. It is very ...
1
vote
0answers
29 views

Shell script for network manager not completing [closed]

I am trying to set up scripts that automatically connect a sshfs mount once I connect to a certain wifi network. My startup script looks like this: #!/bin/sh echo "up" >> /var/log/custom-sshfs....
2
votes
1answer
97 views

Ubuntu 16.04 - how to play a sound from script run from webservice, in background

I am a developper, and have configured a server on ubuntu 16.04, running web services. Those web services are calling some script file locally the script is doing some task, and should play a sound ...
10
votes
2answers
1k views

How does ~/ work? [duplicate]

In the terminal, one way to reference home is by using ~/. I don't understand how this works, because the output of file ~/ is: /home/admin/: directory and just running ~/ results in: -bash: /home/...
0
votes
1answer
71 views

Using bash commands in keyboard shortcuts

I'm trying to set a keyboard shortcut for notify-send $(fortune) but when I activate it, it just sends a notification that says $(fortune) instead of actually giving a fortune. Note that if I run it ...
3
votes
1answer
689 views

Where is the alias for ll defined

I often find myself using ll which is an alias. $ type ll ll is an alias for ls -lh I always wondered where this was defined as it works both on bash, zsh but not on sh: # THIS IS SH $ ll sh: 1: ll:...
1
vote
1answer
384 views

Cron job doesn't read into the shell script function

I'm having a strange situation where cron job is executing a script and doesn't read into the function. Yeah I know, solar flares. On a serious note, the idea here that I have an .sh script which ...
0
votes
2answers
65 views

Bash script for power AC plugin

I'm working on a bash script that runs in an infinite 1 second loop, where if it detects that the computer is plugged into AC power, it plays the file plugin.ogg with ogg123, and if it is not plugged ...
16
votes
1answer
1k views

What does ${0%/*} in shell scripts do?

Sorry if this is a stupid question, but I searched about it without success. What does exactly the second line do ?: #!/bin/sh cd ${0%/*} || exit 1 I know the first is the shebang, the second ...
2
votes
1answer
31 views

Running similar analysis [duplicate]

I have a folder with multiple sub-folders and files. They are all similar in name but the only difference is the patient's number Example Analysis/Patient_01/Brain/image_patient_01_merged.nii ...
1
vote
2answers
1k views

How to avoid /bin/sh -c /bin/bash and /bin/bash running for the same shell script?

I have a test.sh script running in crontab every 10 minutes for the user uni-01 crontab -l */10 * * * * /bin/bash /home/uni-01/test.sh > /home/uni-01/data/_d.log 2>&1 When I use a ps -eF ...
8
votes
4answers
826 views

Run through two sequences in one loop

I'm trying to run through two sequences in the same loop in my shell like below: #!/bin/bash for i in (1..15) and (20..25) ; do echo $i ...... .....other process done any idea how I ...
1
vote
1answer
61 views

How compatible dash is with ksh?

Can I make /bin/sh symlinked to /bin/ksh instead of /bin/dash without breaking anything in the process ? Since they're both supposed to be POSIX-compliant, can I reasonably expect the replacement to ...
0
votes
2answers
480 views

sh - Readonly array: bad variable name

My script runs a program and checks the output with an expected one. Why is it not working?? (Prob an n00b mistake I'm making) Console: dan9er@A-Computer:~/Projects/Project$ ./Script.sh ./Script.sh: ...
2
votes
3answers
792 views

Print two variables in one line

I wanted two print to variables in one line. I am using a shell script #!/bin/sh loop and what I wanted to do is a for repeat which prints out something like: variable1_case1 variable2_case2 and I ...
0
votes
1answer
40 views

How to get partial command line to file

I want to save some text (partial) in command line to file, This my command line for example : sudo gammu sendsms TEXT 08539032xxxx -text "Testing sms dari aplikasi gammu modem" >> log.txt it ...
1
vote
1answer
1k views

Trying To Install Libnotify [closed]

When I run sudo sh autogen.sh I get this output: Processing ./configure.ac Running gtkdocize... Running autoreconf... autoreconf: Entering directory ``.' autoreconf: configure.ac: not using Gettext ...
1
vote
2answers
76 views

Bash script gives warnings / errors although it works as expected. How can I edit to remove warnings / errors?

I use the following script to batch-combine image sequences located inside sub-directories into .pdf files. It works well, but prints errors whilst operating. I am interested in refining the script ...
0
votes
2answers
1k views

Shell (.sh) Compiler [closed]

How can I compile a shell(.sh) file? (S.H.C 3.8.9), I am working only on the same server and not on other servers.
1
vote
1answer
405 views

Bash script and created processes

I have a bash script running as a su cron every 10 minutes. On top of the script I declare: #!/bin/bash In crontab I am running it with /bin/bash. I do the same with all the scripts called from my ...
0
votes
1answer
4k views

exporting environment variable using .sh file

so I have create setup.sh file like this : #!/bin/bash export SP_TWITTER_KEY=adsfad export SP_TWITTER_SECRET=aadsfadsf export SP_TWITTER_ACCESSTOKEN=asdfasdfa export SP_TWITTER_ACCESSSECRET=...
0
votes
0answers
371 views

Automating a bash script FFMPEG [duplicate]

I am having a small problem while trying to create an automated Bash script so I can easily convert webm files into mp3. The piece of code I am using is for FILE in *.webm; do echo -e "...
0
votes
2answers
102 views

Shell know if minecraft is running or not

This applies to any other app that runs under linux via java or any sort of wrapper. Under System Monitor minecraft shows up as "java". this is problematic... what if the java app that's running isn'...
0
votes
0answers
62 views

Ubuntu 14.04 won't install i386 libraries

Alright community, hello there and please help me. I've been trying to run a game from GOG, and their support nor that community have been able to help me. It is a recurrent issue and it got a ...
6
votes
1answer
10k views

Command to perform a recursive chmod to make all .sh files within a directory executable?

Trying to perform a recursive chmod on all the .sh files in a directory to make them executable
1
vote
1answer
814 views

How to increase maxium number of forks in Ubuntu 16.04 [duplicate]

I am attempting to spin up 1000x Docker containers via: nohup docker run --rm --name n-$1-$2 n-v2 bash -c "/root/sw/run.sh $1 $2" 2> ~/logs/log-$1-$2.log & But after about 500x containers I ...
1
vote
2answers
140 views

Showing a message with Crontab

We are looking for a solution that every day of the week, the pc does a shutdown at 8 p.m. The pc has multiple user accounts but always only one person will be using it. There will be several ...