Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

learn more… | top users | synonyms (1)

1
vote
1answer
48 views

Cronjob to push MongoDB Backup via git

Task: Create a Cronjob that executes a bash script once every night. The bash script should do a mongoDB Backup and push it to a Git Repo. So I created a cronjob as the root user via the crontab -e ...
0
votes
1answer
38 views

delete a line if it contain a particular match from a file in bash

I have a file contain lines like the following. 10 TEST NO SOMETHING 20 TEST YES SOMETHING 101 TEST YES SOMETHING 100 TEST NO SOMETHING How can I delete only the line that ...
1
vote
2answers
400 views

execute a script inside another script

I've a script like this: /root/bin/script1.sh putting this line inside .bashrc /root/bin/script1.sh & script1.sh does not run - the problem is &. Without "&" the script run perfectly
0
votes
1answer
105 views

How to allow connections in zimbra/mail client?

I installed a Zimbra server into CentOS 6, enter the admin panel via web HTTPS over port 7071, the problem is I can not access the web mail client (port 445), I can only access via localhost. I ...
1
vote
1answer
51 views

Can't use functions exported from .bashrc in a bash script

My .bashrc file exports a function called lookup: lookup() { grep -r -ne "$1" * | grep -v "TAGS:" | grep -v "tags:" } export -f lookup I can use that function in a shell. But if I put it in a ...
1
vote
1answer
105 views

Pause BASH script to allow user to enter SSH password

I am trying to write a bash script to login to a range of servers and execute some commands, the server which is going to be running the bash script doesn't have EXPECT or SSHPASS installed and I am ...
0
votes
2answers
463 views

Unzip from stdin to stdout - funzip, python

The goal is to read a zip file from stdin and uncompress to stdout. Funzip works and is the solution I am looking for, the zip contains a single file, unfortunately funzip fails when the compressed ...
2
votes
1answer
103 views

How to find out what what's creating temporary files

I notice a lot of empty files in /tmp with names similar to "/tmp/tmp.tMIHx17730". I run audit rule and I found out that mktemp is creating it which is not too helpful. How do I find out which script ...
0
votes
1answer
49 views

Cron Apache Access Log Keep Certain Lines Remove Duplicates

I'm trying to create a nightly cron that keeps certain lines from the access_log (into a file), then removes (near) duplicates from that file, then empties the access log and restarts Apache. I have ...
3
votes
3answers
124 views

cron: send email to different address in case of failure

I've a cronjob like this: MAILTO=mymail@mydomain.com 30 00 * * * root /run/this/script.sh is there a way to tell cron to send mail to different mail addresses based on exit code? I mean, can cron ...
3
votes
1answer
202 views

bash if statment unexpected behavior in crontab job

Here is the script bash --version | head -n1 if [ "$1" == "now" ] then echo if now execut job else echo else "_"$1"_" # make sure we are not picking any spaces if [ condition ] ...
-1
votes
2answers
44 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 ...
0
votes
1answer
392 views

PHP script error 'exec(): Unable to fork…' on Ubuntu 14.04.3 LTS

I'm running unittest scripts and for test case setup I need to run shell command from time to time. As a result shell command is run around 50 times during unittest execution. It works ok on CentOS ...
1
vote
3answers
126 views

Run bash script as sudo from windows without interaction

I need to execute a bash script as sudo on a remote linux machine from TeamCity running on a windows box. I can execute the script fine from the cmd line using plink, but I am prompted for a password....
3
votes
2answers
100 views

How can I combine two commands to tally data from compressed and uncompressed log files?

I am running this command to get a tally of failed login attempts from a server’s auth.log and it works well: sudo cat /var/log/auth.{log,log.1} | grep 'Failed password' | grep sshd | awk '{print $1,$...
1
vote
2answers
31 views

Echo Variable - Same way, different output

I wrote a shell script with the following content: #!/bin/bash value=`cat test.txt` echo "Output: $value" >> currentOutput.txt By executing this script in shell, it writes correctly the ...
2
votes
1answer
259 views

how to delete old files in ftp with bash

I have a backup ftp server and I have a CRON bash sending all backups here. Right now I have to manually delete all old files, but I would like to automate this process with a CRON bash The remote ...
0
votes
0answers
21 views

SSH client - prompt editable as Windows control

Is there a way to configure PuTTY (or some other SSH client) to be aware of what's currently typed into the prompt and make it editable via the mouse (like in an input box / textfield that shows at ...
1
vote
2answers
131 views

Attach timestamp to each line of stdout

Im am hosting some game servers, and each server instance runs in stdout, but they don't have timestamps, just logging events to new lines, e.g.: player a connected player b connected game started ...
0
votes
0answers
12 views

Network restart script does not complete as a cronjob [duplicate]

I have this simple script on crontab (root): (centos 6.5) if ! ping -c 1 172.20.1.1; then echo "NOT OK" >> /root/log ifconfig eth3 down sleep 5 ifconfig eth3 up else echo OK >> /root/log ...
-1
votes
1answer
219 views

Bash command in PATH to be run from PHP script [closed]

in Debian 8, I'm trying to create a script I can put under /sbin (which is in my $PATH environment variable), so it can be run, the command is a simple echo of a few lines. I've created a bash script ...
0
votes
0answers
39 views

Solaris 10 - after user shell change X won't start

I've created user with default shell bash, after some time I need to change default shell to /bin/sh (default Solaris 10 user shell) for practical reasons. After execution of command: usermod -s /...
-1
votes
1answer
333 views

What shebang for Anaconda Python on my directory of Server

I have anaconda python distribution in ~/anaconda/bin/python but what shebang can I use to call this version of python instead of the old one that is default on the server? # /opt/python/bin/python2....
2
votes
1answer
33 views

split filename in loop and reference each part

I have a directory with a list of files in it, e.g. file.name.aaaaaa.111111 file.name.bbbbbb.222222 file.name.cccccc.333333 I need a way to take each file, split it at the "." and then using each ...
0
votes
1answer
99 views

Install lamp-server on EC2 at start-up

I passed some scripts to EC2 userdata to install at starup. One of those is sudo tasksel install lamp-server When this process runs, it prompts for mysql password,twice, to bypass this, I use sudo ...
2
votes
1answer
93 views

How can I use openssl to get results from HTTP GET requests?

I need to use openssl to perform some HTTP GET requests in a shell script. The line I'm using to do this right now is shown below. This is parsing the content of an XML response of the following ...
1
vote
1answer
143 views

Bash: How do I pass “command not found” text into my trap function?

I have the following: test.sh . Foo.sh Foo.bar Foo.baz Foo.blah and Foo.sh function Foo.bar() { echo 'I am a bar!' } function Foo.baz() { echo 'But, I am a baz!' } function Foo.error()...
1
vote
1answer
137 views

Bash script working in command line but not through PHP

I'm attempting to run the following command through PHP: $output = shell_exec('sudo /Users/Derk/Code/automation/psc/pdfs.sh 1'); This runs the following bash script code: sudo /usr/local/bin/pdftk ...
-2
votes
1answer
137 views

How do I SSH through a jump server into a Rails console?

I'd like to have a one-liner for this. When I use the following command: ssh -o ProxyCommand='ssh -W %h:%p user@<jump server>' -t user@<rails server> 'sudo su another_user ; cd /some/dir ;...
2
votes
2answers
161 views

Setting systemwide environment variables which are read when a shell is started

What's the preferred way to set environment variables for all users (on Ubuntu) such that the new variables are read whenever a new shell/terminal is started? Presently, we're using a file in /etc/...
1
vote
2answers
561 views

Change MySQL root password with bash script

I'm attempting to create a bash script to change the MySQL root password, below is the current snippet of code I am working with: #!/bin/sh clear echo "Enter the current password for the root mysql ...
0
votes
1answer
25 views

Typing in terminal interferes with `nc` running in background?

I can run these two commands: nc -l localhost 8888 -v >> output.txt & (while true;do sleep 1;echo a;done)|nc localhost 8888 & All works as expected with output.txt filling with "a"s (...
-1
votes
1answer
43 views

Linux Website Testing Tool [closed]

I am looking for a tool to test a website from a Linux command line. From the output, I need to know the response of website that user is able to login with username and password.It will help me to ...
0
votes
1answer
79 views

Start multiple rsync sessions

I want to start multiple rsync sesssions via screen in detached mode? Is it possible? I need to run rsync script for each file in folder. screen -t -d sshpass -p 123456 rsync5 rsync -avzP /home/...
0
votes
0answers
27 views

How to run script automatically after specific time? [duplicate]

I have two scripts to run backup task, one is for full backup, another one is for incremental backup. I want to run full backup at specific time every day, and run incremental backup every 10 mins ...
1
vote
0answers
28 views

Simple anti DDoS protection in FreeBSD [duplicate]

I have a lot of request from data centers to my web server on FreeBSD and sometimes it've have a lot of performance problem with my web projects. Adding to IPFW list all IP's data centers is ...
1
vote
1answer
135 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 (...
0
votes
3answers
279 views

How to use expect in Bash script and ssh-copy-id

From a bash script: source ./expect.sh I am including a expect code: #!/bin/bash /usr/bin/expect <<EOL spawn ssh-copy-id -i /home/user/.ssh/id_rsa.pub 111.111.111 expect '*?assword*' send '...
0
votes
1answer
17 views

Calculate Receiving Postfix Mailserver Successful Delivery vs. Failure

I'm trying to calculate a rough percentage of how much email my mail server processes for successful delivery vs. how much it drops on the spot as email coming from misconfigured mail servers, spam, ...
1
vote
2answers
58 views

Where to set bash settings for the user “mysql”

Please excuse me if the question is misleading. I'm trying to understand the way the environment settings work for the user "mysql". I'm following this guide to connect an Oracle DB from a MariaDB ...
2
votes
1answer
91 views

Is it possible to measure the used bandwidth per port on linux?

I am wondering if there is a way to measure bandwidth by a tcp/udp port under Linux? Means I search for a way to be able to tell, tcp/53 needs now 1MBit/s, tcp/80 needs now 4.5MBit/s. iperf is able ...
0
votes
1answer
117 views

How to list uid of all the users of LDAP?

I get list of all the users of LDAP using the following command ldapsearch -x -LLL uid=* > result. The result of the following command results in following format dn: uid=shahrukh,ou=People,dc=...
3
votes
2answers
212 views

Pressing Ctrl-C stops bash script, but don't stop PHP script called by the script

I need to run a few scripts every few minutes. The logic was made in PHP, and it's working great. To keep things together I've made the bash script below, which also runs fine. #!/bin/bash ...
1
vote
0answers
53 views

mysql-cli - force quit on timeout / connection drop

I have set timeouts in /etc/profile.d/ to disconnect inactive users using TMOUT and this works great however now I am seeing users just holding their connection open by keeping some foreground process ...
1
vote
1answer
366 views

Linux find: How to exclude the “.snapshot” directory from find's results?

I wrote a rsync script which uses find command to find all files which are older than 10 minutes and copies them to a remote server. The relevant part of the code is: print_log "------ Starting $0 --...
2
votes
2answers
81 views

Split large Logfile with Suffix like from logrotate

after I've seen that I forgot to add a logrotate-conf for php5-fpm.log on one Server, and now seeing that it has grown REALLY big, I'm asking myself how to split this Logfile into separate ones, with ...
1
vote
1answer
152 views

subshell is not created if run commands without a path?

I'm reading the book "Linux Command Line and Shell Scripting Bible" 3rd edition. On page 279, here I quote: "Command substitution creates what's called a subshell to run the enclosed command. A ...
3
votes
2answers
891 views

Why use `bash -c` in supervisor instead of calling script directly?

I'm beginning to use supervisord to control services in my server. I'm not a pro user of linux but can get with it quite well and get it running. Just out of curiosity, I've noticed that most ...
3
votes
2answers
132 views

top output to narrow in cron

I'm trying to send an email through cron to know what processes are hogging my server. It works fine but the resulting email is too narrow and I need to know more about the process. This is the ...
2
votes
1answer
85 views

How to check root environment variable from sudo user?

How I may check root environment variables from sudo user? I tried various keys and combinations of su and sudo, but have no luck. For example, $HISTFILESIZE=2000 for ordinary user and 9999 for root ...