Questions tagged [sh]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

Add sh aliases into docker container via docker-compose.yml

I want to add useful aliases or functions into various docker containers. So in docker-compose.yml I bypassed the entrypoint, added aliases, then ran the normal entrypoint: entrypoint: sh -c ' ...
0
votes
0answers
91 views

mask FQDNs from any command output (for diagnostic)

Very similar to this other request (now resolved): mask public IP addresses from any command output (for diagnostic) I'm looking for a safe masking option to hide FQDNs from command line outputs. The ...
1
vote
1answer
65 views

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 ...
0
votes
1answer
45 views

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 ...
0
votes
0answers
33 views

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....
1
vote
2answers
78 views

Compromised CentOS 6.10 server

I am working on a compromised server. CentOS 6.10 with [kthreadd] taking up most of the CPU. Old crontab deleted, and the following content put in place: */4 * * * * R=$(shuf -i 1-29 -n 1);sleep ${...
1
vote
1answer
208 views

Shell script prevent switching to other shell or escape from it

If in my automation script, I need to do something like install oh-my-zsh, I will have a .sh script like this: #!/bin/sh runuser -l user -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/...
0
votes
1answer
74 views

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 ...
1
vote
0answers
197 views

Why are psql commands in my script suddenly being killed by jenkins / hudson?

I have an existing jenkins job that kicks off a shell script to copy my prod environment into qa. We added a lot of data to prod (gzip dump went from 2gig to 15gig) and all of the sudden my jenkins ...
0
votes
1answer
2k views

commands not running from crontab [duplicate]

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 ...
0
votes
1answer
232 views

Set alias from sh script in ESXi 6

I have created a simple script to setup an alias on an ESXi 6.7 host: #!/bin/sh alias ll="ls -la" echo "Profile done" When I run the script I see the echo'd message on screen, but the alias is not ...
0
votes
0answers
443 views

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 ...
10
votes
4answers
25k views

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 ...
37
votes
3answers
6k views

#!/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 ...
0
votes
1answer
735 views

How to escape double quotes and exclamation mark in password?

I have the following code: curl -s --insecure -H "Content-Type: application/json" -X POST -d "{\"username\":\"$1\",\"password\":\"$2\"}" http://apiurl In the above curl command I want to escape the "...
0
votes
1answer
78 views

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 * * * * /...
0
votes
1answer
405 views

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: ...
0
votes
4answers
3k views

After launching .sh script appearing 'must be connected to a terminal'

i have a short bash script which can run a file. When im trying to start this by "x.sh start", there is appearing a warning 'must be connected to a terminal'. How to start this? I tried some configs ...
2
votes
1answer
115 views

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.
2
votes
1answer
8k views

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/"* ]] ...
0
votes
1answer
3k views

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 ...
-1
votes
2answers
481 views

Downloading .sh file from git repository [closed]

I am trying to download a file from my git repository onto a VM, and I do so running the following command: curl -O "https://git.com/projects/RENG/repos/test.sh" -k After I run this command I see ...
1
vote
0answers
251 views

Hundreds of zombie sh processes spawn then die

I have a few Ubuntu Server 14.04.03 LTS boxes that will occasionally spawn hundreds of zombie sh processes. This process spike will be picked up by the monitoring system, and send an alert. I found ...
2
votes
1answer
2k views

How to watch for arrivng files if inotifywait unavailable? [closed]

I have a directory that gets written to when other machines send files via FTP. I want to put something in place that notices when files arrive and if their file name contains a particular substring (...
2
votes
0answers
842 views

Init script has permissions issues, but running with /bin/sh resolves them? [closed]

Can someone tell me what's going on here? As far as I knew, these ways of executing an init script are identical. box:~# whoami root box:~# /etc/init.d/nginx restart nginx: [emerg] open() "/var/run/...
-3
votes
1answer
901 views

How can I execute sibling scripts outside the directory? [closed]

$ ls -l bin/ $ ls bin/ startup.sh shutdown.sh I wrote a script named restart.sh inside the bin/ looks like #!/bin/sh sh ./shutdown.sh sh ./startup.sh Now the bin/ directory looks like this. $ ls -...
1
vote
2answers
2k views

script to count the occurence of the particular string in the given time interval

We are trying to write a script "sendemail.sh" to count the number of occurrence of a particular string in a log file "SendEmail.log" within the given interval. We have a log file. In that we are ...
-4
votes
1answer
256 views

Killing a bash sh script [closed]

I made an .sh file load.sh which has (almost) unlimited loop of curl requests. I run this as $ bash load.sh. Now it just keeps running the loop. I can't cancel its execution. It keeps running. I ...
0
votes
2answers
1k views

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 - # <-...
0
votes
2answers
311 views

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 ...
0
votes
1answer
2k views

sh bash script ambiguous redirect pid of file using single quotes

I have the following new line in my .sh file su --session-command='$javaCommandLine & >>$serviceLogFile 2>&1 & echo \$! >$pidFile' $serviceUser || return 1 When I had it with ...
0
votes
1answer
99 views

rkhunter warning message /bin/sh

I'm running Ubuntu 10.04.4 LTS with fully update OS. The below messages is from rkhunter, What does it mean? Can anyone please explain. Warning: The file properties have changed: File: /bin/...
3
votes
3answers
257 views

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.
-1
votes
1answer
137 views

Host command reverse result [closed]

For example I do in Linux using host command: host yy.yyy.yy.y Result: Host z.zzz.zz.z.in-addr.arpa. not found: 3(NXDOMAIN) Then I repeat host command in a reverse with z.zzz.zz.z than I got a ...
-1
votes
2answers
912 views

run ntpdate from rc.local [closed]

My /etc/rc.local is: #!/bin/sh touch /var/lock/subsys/local /data/automatic/ntpdate.sh My /data/automatic/ntpdate.sh is: #!/bin/sh echo "RWQERWER" >> /data/logs/1.log ntpdate ntp.fudan.edu....
1
vote
1answer
308 views

Multiple spaces in folders and files for rsync backup via /bin/bash /bin/sh

Need a one-time backup of two old messy Windows XP machines because of a company split. Using CentOS 6 x64 minimal install, i mounted some MS Windows NTFS harddrives installed locally via ntfs3g and ...
3
votes
2answers
223 views

`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 ...
0
votes
1answer
55 views

update all the servers through one virtual servers using Storage are network virtual machine

Using UBUNTU and Virtal Box by Oracle, and Using this script to start nginx in Virtual Box, and placing it in Virtual box inside~/init.d #!/bin/bash ### BEGIN INIT INFO # Provides: ...
0
votes
1answer
114 views

date and other commands no longer working in sh script

I have a shell script that used to run find on Ubuntu 10.04 but since I have moved to 12.04 it doesn't work as before throwing the following messages: /home/checks.sh: 1: /home/checks.sh: date : not ...
2
votes
2answers
234 views

how to remove ^m symbol

I need to compile Qt under Debian 64-bit. I downloaded sources but there is ^M symbol everywhere in every file in the end of lines and bash doesnt run configure script. How to remove it from all files ...
1
vote
1answer
2k views

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 ...
0
votes
4answers
981 views

Assigning environment variables for CRON

I have a .sh script that creates a .tar.gz file and transfer's it to a remote server using RSA keys for authentication. The script will run from terminal but it will not when I try to set it up as a ...
7
votes
2answers
3k views

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 >...
3
votes
3answers
1k views

SH conditional redirection [closed]

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 ...
2
votes
4answers
2k views

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 ...
1
vote
1answer
116 views

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:...
1
vote
2answers
1k views

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 ...
2
votes
3answers
2k views

FreeBSD rc.d script doesn't work when starting up

I am trying to write a rc.d script to startup the fastcgi-mono-server4 on FreeBSD when the computer starts up - in order to run it with nginx. The script works when I execute it while being logged in ...
4
votes
3answers
4k views

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. ...
0
votes
1answer
143 views

Directory replication in New server

Scenario is to replicate all the directories,sub-directories,files,symbolic links present in Linux development Server to Linux QA Server. Lot of unix users also to be created. Consider an unix ...