Questions tagged [sh]
65 questions
38
votes
3 answers
#!/bin/sh vs #!/bin/bash for maximum portability
I usually work with Ubuntu LTS servers which from what I understand symlink /bin/sh to /bin/dash. A lot of other distros though symlink /bin/sh to /bin/bash.
From that I understand that if a script uses #!/bin/sh on top it may not run the same way…

cherouvim
- 794
- 3
- 21
- 37
16
votes
1 answer
can't type lower cased e in amazon ec2 (Amazon Linux)
After a few days of operation on my new ec2 build, the following happens:
I log into SSH, everything is fine, I do my coding
I return the next day, and log into SSH
I cannot type a lower cased e anymore--I get the error ding when I type it
I try to…

Kato
- 263
- 1
- 7
14
votes
1 answer
How to change default shell in FreeBSD?
The default shell in FreeBSD is sh and I really can't stand it: autocomplete is very limited, and rehash commands kill me. I feel like a one armed and one legged man...
How can I change the shell globally to zsh or bash - for root and for all…

holms
- 1,524
- 7
- 20
- 37
10
votes
4 answers
Shell script from local machine to execute command in remote machine, then continue on the local machine
The problem is this: I want to copy files from a remote machine.
I am looking for a way to write a shell script that would connect to the remote machine, get the location of the stored file, once I get the location disconnect from the remote server…

gnsr
- 103
- 1
- 1
- 5
8
votes
3 answers
FreeBSD 8.2, deleted /bin/sh, can't boot
I made a really bad decision on one of my servers.
I deleted /bin/sh. I restarted the server and the server won't run because it needs /bin/sh to start the rc scripts. I can't access single user mode either because sh is needed.
Is there any easy…

jon
- 81
- 2
7
votes
2 answers
How do I enable XRandR in Xvfb or disable it in firefox when running firefox headless?
I am trying to start firefox headless. The following is the beginning of the shell script that starts it:
#!/bin/sh
Xvfb :99 >/dev/null 2>&1 &
XVFB=$!
sleep 3
firefox --display=:99 >/dev/null 2>&1 &
FIREFOX=$!
When this script is run, the…

Utkonos
- 416
- 4
- 15
5
votes
3 answers
How do I get ssh to run in the background without using -f?
I'm attempting to create an ssh tunnel, spin it off into a background process, and write a pid file which I can later use to kill it. I CAN run ssh with -f, but then I don't have a handle on its PID.
However, when I attempt to run the script below…

vezult
- 420
- 2
- 6
- 15
3
votes
1 answer
Linux shell script "No such file or directory"
I have created a shell script to complete 3 simple tasks (zip a directory, rename the final file and delete the source directory). The script source is below:
#!/bin/bash
if [[ $2 == *"/data/"* ]]
then
src= $2"/*";
dest= $1".zip";
#…

h2odev
- 133
- 1
- 1
- 3
3
votes
1 answer
AIX update environment after .profile change
I am running AIX 5.3. I have made changes to a user's .profile file (added a couple of environment variables).
Is there a command that I can use to re-process the .profile file for a particular user without them having to log out and then back…

Buggabill
- 179
- 2
- 10
3
votes
3 answers
How can a sh script determine if it was started as a cron job as opposed to interactive or background?
I'd like to use the same scripting for cron and interactive, just wondering if there was a universal way over UNIX/Linux systems to easily make this determination.

mdpc
- 11,856
- 28
- 53
- 67
3
votes
2 answers
`sh` access denied over ssh connection
I have an ubuntu server and a windows XP client running Cygwin. The server ssh's into the client and tries to execute a shell script with some params, with the following command:
ssh user@IP_ADDR 'sh /home/user/project/clientside 2 5 7 6 9 5 7…

inspectorG4dget
- 151
- 5
3
votes
3 answers
SH conditional redirection
I want to be able to redirect some output of my script to /dev/null based on a command line switch.
I don't know how should I do it.
In a silly way, it would be something like this (in a too simplified way):
#!/bin/sh
REDIRECT=
if [ $# -ge 1 -a…

j4x
- 105
- 7
3
votes
5 answers
How to execute shell scrips without creating files
How is it possible to execute a shell script without creating a file? For example assume I have the following script (testscript):
#!/bin/bash
function run_free() {
free -m
}
run_free
I then of course can execute this with: sh testscript
I want…

Justin
- 5,328
- 19
- 64
- 84
2
votes
1 answer
In bash script, what is difference between > and >| redirections?
What is the difference between the following two redirection commands?
ls > out
ls >| out
They both seem to produce the same output.

GoodMirek
- 203
- 2
- 8
2
votes
1 answer
What's the accurate meaning of "exec &>/var/log/a.log" in a shell script?
I think this is some kind of io redirect but it looks different to the examples from manual. Normally, we can redirect stdout of the script by following line:
exec 1> /var/log/a.log
But I saw this line in one of script:
exec &>…

James Gan
- 386
- 1
- 5
- 10