Questions tagged [sh]
65 questions
1
vote
1 answer
Run .sh (no service) file on startup
How to execute a script once at startup time on CentOS 6.3? I added file with following containment
#chkconfig: 2345 95 20
#description: Some description
sh /opt/somePath/my.sh
into /etc/ini.d and it works fine (I executed required chmod,…

MyTitle
- 551
- 1
- 8
- 18
1
vote
1 answer
Does the sh command use the users shell
Does the sh linux command use the users current shell, even if its not bash? For example, let's say the user bob is running csh. If I create a script with functions and csh and try and execute it with:
sh cshtestscript
Will this run with csh?
Then…

Justin
- 5,328
- 19
- 64
- 84
1
vote
2 answers
PHP, SSH2, and Bash Scripts not getting along
I am using the SSH2 library in my PHP to execute a SH script on a remote server. When I run it manually on SSH, it works just fine. However, when I try to run it through PHP, the script starts, but never completes. (The script echos the size of two…

DarthCaniac
- 209
- 1
- 3
- 8
1
vote
2 answers
Is there a way for me to simplify this subversion pre-commit hook?
Is there a way for me to simplify this pre-commit hook? It seems a bit much to me
#!/bin/sh
message=`$SVNLOOK log -t "$TXN" "$REPOS"`
# Block any commits which don't reference a ticket
if echo $message | grep -q "re #"
then
:
elif echo $message…

David
- 157
- 2
- 9
1
vote
2 answers
8: Syntax error: word unexpected (expecting ")")
The following code:
weekday=$(date +%a)
day=$(date +%d)
month=$(date +%m)
if [[ ( $month == 03 || $month == 10 ) && $weekday = "Sun" && $day > 24 ]]
then
# DO SOMETHING
exit 1
else
# DO SOMETHING
fi
leads to the…

Omexlu
- 43
- 1
- 9
1
vote
1 answer
mask public IP addresses from any command output (for diagnostic)
I'm writing a script to extract information from BusyBox v1.25.1/Linux 2.6.36/router where the user can simply run the script and copy/paste the output into a submission form to request support. The script it's essentially a list of commands like…

rs232
- 105
- 1
- 10
0
votes
1 answer
How to run a shscript on reboot
I am trying to run a script on reboot that enables a port forward to a remote server. I made i script that it works if i run it in terminal. But i am not able to run it on crontab reboot:
@reboot sleep 120000 && sh /home/user/doit.sh
where i can…

Kaf
- 169
- 9
0
votes
0 answers
executing part of script coming from external file
I have some information stored in an external file.
On the main script I'm parsing the secondary file to work out how information should be processed.
To do so I have tried this:
cat ./secondary.file
file:block.txt…

rs232
- 105
- 1
- 10
0
votes
1 answer
Bash command to execute a foreground set of background commands
I got 2 commands that run blocking the input in the console, so they must be ended with CTRL+C. I don't like running them in background, since I lost control for interruption. But otherwise I cannot execute them sequentially in a one-liner since…

Whimusical
- 103
- 4
0
votes
1 answer
commands not running from crontab
I have setup and cron to check if a port is busy or free and if its free then it sends and email and then start golang api service
send mail is working properly but api server is not getting started
following is my crontab file
*/2 * * * *…

Vikram
- 167
- 2
- 10
0
votes
0 answers
linux sh -c replace echo not working
This seems like it should have a super simple answer, but I have search for a while and tried different suggestions to no avail.
As an example, I am trying to create a function that will be available when the following is ran
sh -c "echo 'test…

syntencoist
- 21
- 4
0
votes
1 answer
Multiple crons at same interval fails - linux crontab
In my server, I have scheduled following set of cron files.
00 21 * * * /bin/sh /path/db_backup.sh
*/2 * * * * /usr/bin/php /path/file1.php
*/2 * * * * /usr/bin/php /path/file2.php
...
*/2 * * * * /usr/bin/php /path/file7.php
*/2 * * * *…

Tamilvanan
- 103
- 2
0
votes
1 answer
How to switch user in a shell command
I am creating a shell script to automate our certificate import process.
It will be running as root to update group policy.
Once complete, how can we change the root to logged in username in MAC?
Ex:
#!/bin/bash
VERSION=1
#Internal network check
…

Deepak
- 1
0
votes
2 answers
running a remote shell script that switches to a user does not return to the issuing local server shell
When I run a script such as this:
ssh -t root@10.10.10.10 '/tmp/somescript.sh'
where the script is defined as:
#!/bin/sh
mkdir -p /data/workday/cred
chown -R myuser:myuser /data
su myuser - # <------- NOTICE THIS ! ! ! !
rpm -Uvp --force --nodeps…

gextra
- 205
- 2
- 6
0
votes
2 answers
Why does system lag or stall after successful completion of tar backup command?
I have a script that runs backup of system files via tar as a cronjob for my server. Every time the script is being fired off, it completed the task as successful. All backups were tested and appeared to be working and not corrupted.
But, my system…

Faron
- 107
- 6