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

learn more… | top users | synonyms (1)

1
vote
2answers
1k views

Inserting multiple lines into a sqlite column with bash script

I am trying to insert a value into my sqlite DB that consists of multiple lines and special characters. For example: { "foo"="$BAR" } I have been using the sqlite3 command but I dont know how to ...
0
votes
1answer
46 views

SSH and sudo over a pseudo-tty terminal

I am trying to overcome some limitations in our environment to write up an authorized SSH file for passwordless ssh keys. I am requiring to perform an ssh as a to a target system, and then run a "...
0
votes
0answers
9 views

Exim script to output the sender and receiver

We have an anti-spam system that sometimes create false-positives. When reported, we verify and whitelist the domains or IPs that have been wrongly triggered. However, I'd like to automate this by ...
1
vote
1answer
25 views

Is there a way to check if my Virtual Memory Paging is “System Managed”

For one of our applications, we need to configure virtual memory on a Windows Machine to be system Managed. This can be done manually under System Properties -> Performance (Settings...) -> ...
0
votes
1answer
12 views

Timestamp comparison on AIX without date -d

I have a bash script on AIX 7 that runs a database query and the output I get is a timestamp in the following format: 201607130319 Now I would like to compare the timestamp with current time(date +%...
0
votes
1answer
1k views

OpenVPN run script after tunnel is set up

I'm having a hard time figuring out exactly how can I update my A records on my cloudflare account. I have already set up a script that checks for IP changes, and pushes the changes through the ...
1
vote
2answers
104 views

Bash scripting error checking using word count and awk

Need a light on my script I am doing a word count on a variable get a 0 or bigger value but it seems the script is breaking at on this variable function count_check=wc -l $TABLE_CHECKS | awk '{print $...
0
votes
1answer
45 views

Error with a specific bash script

I must first of all shamefully admit that I unfortunately know nothing about scripts... I am simply trying to use one that seems to fit my goal. I am running a VPS node with OpenVZ, and I need a ...
0
votes
1answer
38 views

nginx stop logging after crontab modified the log file

I have a web server(django) running on nginx + gunicorn. nginx writes its regular logs to: ~/myproject/log/access.log and it writes errors to: ~/myproject/log/error.log it works pretty well for ...
1
vote
1answer
291 views

mailx command strange behaviour from cron

I have a script that redirect the df output to a file and then send it in an email. The mail command is set up as following: /usr/bin/mail -s "Subject" -r from@nowhere.com toaddress@somewhere.com <...
1
vote
1answer
48 views

How to get the output of the python script executed in aws instance

I am trying to automate the aws instance setup using boto. I have a python script in which I will do the ssh to the instance. After ssh,I am executing a python function which is in remote python file ...
0
votes
1answer
19 views

Can I filter output from `tail` with the `-f` flag?

I'd like to tail -f the output of access_log on RHEL 6.8 but pipe and grep that output to act as a filter. Is there such an option? That is I'd like live output from: # tail -f error_log | grep <...
1
vote
1answer
18 views

How to make bash treat variables as strings using process substitution

I have the statement: A=$(echo "echo a") && bash -c "awk -v var=\"$A\" 'BEGIN {printf \"%20s\", var}'" Which outputs: echo az And I can't make this one-liner work: A=$(echo "...
0
votes
1answer
56 views

bash script works correctly but skips commands in cron if I am not logged in via ssh or I was connected recently

I am trying to schedule some backup scripts in cron on a CentOS release 6.7 (Final). This is the full backup, basically mounts a remote directory, checks if there is enough space available for doing ...
5
votes
1answer
146 views

mysqldump via bash script failing with “No such file or directory”

This one's driving me NUTS. Any help appreciated! $MYSQLDUMP --login-path=$HOST $DATABASE > "$BACKUP_DIR/${HOST}__${DATABASE}__${NOW}.sql"; I've confirmed that the binary $MYSQLDUMP (within the ...
0
votes
1answer
9 views

No SQL result output from sql executed from bash

When executing an SQL from a shell like this, the sql result output isn't printed. How do I do it ? mysql -uroot -p < /root/queries.sql Edit: When the content of the sql is a SELECT, I do see ...
4
votes
1answer
149 views

lspci “Memory at…” vs /proc/bus/pci/devices BAR address

I have a userspace application that I use to write to the registers of a pci device. It takes the base memory address of the device as an argument. Instead of looking this up via lspci on each ...
38
votes
6answers
42k views

What is “-bash: !”: event not found"

Try executing the following under a bash shell echo "Reboot your instance!" On my installation: root@domU-12-31-39-04-11-83:/usr/local/bin# bash --version GNU bash, version 4.1.5(1)-release (i686-pc-...
0
votes
0answers
6 views

Capture all output, error, warning and their appearance order of linux's command [migrated]

In linux we can redirect stdout and stderr or both of them to files. For example: Redirect stdout and stderr to two files: command 1>out 2>err. By this way, we can separate output and error in ...
37
votes
6answers
11k views

Can you have more than one ~/.ssh/config file?

We have a bastion server that we use to connect to multiple hosts, and our .ssh/config has grown to over a thousand lines (we have hundreds of hosts that we connect to). This is beginning to get a ...
0
votes
1answer
99 views

How can i recover bash history while i accidentally typed reboot -f

Scenario : After working on my Linux server [CentOS 7] ,I typed reboot -f in my terminal, is it possible to retrieve my bash history after rebooting it? I understand that reboot -f will forcefully ...
2
votes
1answer
1k views

Improper output in SSH session on OSX using FreeSSHd on Windows with cygwin bash/sh shell

I am testing out running an SSH server on a local Windows VM. I have installed FreeSSHd and set the command shell to "c:\cygwin\bin\sh --login -i" (bash as well) with "Use new console engine" ...
3
votes
4answers
2k views

cpio VS tar and cp

I just learned that cpio has three modes: copy-out, copy-in and pass-through. I was wondering what are the advantages and disadvantages of cpio under copy-out and copy-in modes over tar. When is it ...
0
votes
1answer
2k views

Using curl with cookies

I hope someone can help me out on this one. I have been trying this for a while now, with all sorts of variations and cannot seem to get this to work. I am trying to script a way to log in to https://...
0
votes
0answers
20 views

Different behavior of the cron [duplicate]

I have a script (seekCustomers.sh), which perfectly works from the command line: #!/bin/bash echo "Hello" The script is owned by non-root user. I want to put it on schedule using cron daemon. So, ...
0
votes
1answer
17 views

URL encoding issue with cron and wget

I have a simple bash script: #!/bin/bash wget -q 'http://requestb.in/1fq0r3s1?foo=a%2Bb' -O /dev/null If I run this from the commandline and then inspect at http://requestb.in/1fq0r3s1?inspect I ...
-1
votes
1answer
35 views

What is the equivalent of chdir for UNIX?

I'm working on OSX 10.11.4 trying to write a simple bash script. I'm getting command not found when I try to use chdir. When I test with which chdir I get nothing. What's going on? I'm using this ...
0
votes
2answers
62 views

How to filter (out) certain output in bash

I have a process that tails our AWS CloudWatch logs. It works great, except for the fact that every line is prepended by the CloudWatch group and container ID. For example: core-api ...
1
vote
4answers
1k views

shell script in crontab, not all output being logged

I've got a simple shell script that runs a few LFTP commands and processes the files. When running straight from bash I get full output of those LFTP commands on screen. When running from crontab ...
2
votes
1answer
1k views

JBoss EAP 6.2 on RHEL 6: ./bin/init.d/jboss-as-standalone.sh hangs while calling via SSH

I'm using jboss-as-standalone.sh to manage JBoss EAP standalone as a service. I can start/stop the service with "service jboss-as-standalone.sh start/stop" while I'm on a terminal. But I would like ...
0
votes
2answers
38 views

How to pass variables from one vm to another vm using bash script

What is the proper way to pass variable from one machine to another machine via bash script? In the below code I am trying to get the input from user and want to pass the same to remote machine, but ...
0
votes
1answer
24 views

linux + get standart output from remote machine

is it possible to get the standard output from remote machine - 100 or 1 , After ruining the script /tmp/script.bash ? ssh $remote_machine /tmp/script.bash echo $? ( from remote machine script - ...
10
votes
8answers
24k views

How do I read multiple lines from STDIN into a variable?

I've been googling this question to no avail. I'm automating a build process here at work, and all I'm trying to do is get version numbers and a tiny description of the build which may be multi-line. ...
1
vote
1answer
45 views

Can't access apache webserver remotely after connecting to VPN

I have an apache webserver installed on my pc whcih works as expected untill I connect to my VPN service provider (Private Internet Access) using their software. Once connected I'm no longer able to ...
4
votes
3answers
8k views

How to use ssh and sudo together in bash?

I haven't been able to find a question that describes this specific scenario. I am trying to execute a very basic bash script to retrieve logging from multiple machines. I am running the script ...
0
votes
1answer
19 views

Adding /etc/environment makes bash fail

On RHEL 6.7, I've added the file /etc/environment: JAVA_HOME="/opt/jdk1.8.0_91" JRE_HOME="{JAVA_HOME}/jre" M2_HOME="/usr/local/apache-maven" M2="{M2_HOME}/bin" PATH="{JAVA_HOME}/bin:{JRE_HOME}/bin:{...
3
votes
2answers
2k views

Shell script for docker ps -a | grep to find number of certain containers running

I want to write a script that is executed by my development build server that will remove any 'similar' docker containers before building and running a new container. Below is pseudo code for the ...
0
votes
1answer
2k views

Monit failed to start shell script

So I am having a problem with monit starting a process this is my code: check process program_1 matching "program_1" start program = "/home/user1/files/start.sh" stop program = "/home/user1/files/...
1
vote
1answer
2k views

Nginx how to run shell script on page load via lua module os execute and then serve directory listing?

So I have a bash script that I want to execute/run on each "page load" of url so that it will modify (creating symlinks) to a /public/html/ folder that I want the server to then serve. The problem ...
1
vote
1answer
35 views

systemd service shuts down on its own

I have a problem with this SystemD service: [Unit] Description=RTC Client Services After=rds.service Requires=rds.service [Service] User=USER Group=GROUP PermissionsStartOnly=true RuntimeDirectory=...
55
votes
3answers
20k views

What are the functional differences between .profile .bash_profile and .bashrc

What are the functional differences between the .profile, .bash_profile and .bashrc files?
3
votes
1answer
88 views

Strange behaviour ssh -> bash --> (tty no echo) --> c program?

At job we have an old C program which works with industrial hand terminals from Honeywell. That terminal has its own ssh client to connect to a linux redhat 6.6 server. Once it is connected to the ...
0
votes
0answers
12 views

parallize postgres queries with bash and psql?

I'm trying to run a series of postgres functions/stored-procedures that operate on separate tables in parallel using bash + psql as follows: psql -d samples_20160612_0616 -c "select insert_function('...
0
votes
0answers
88 views

Install Bash + openSSH on Windows Server 2012

I had to create a Virtual Machine with Windows Server 2012. Now I want to connect to it via OpenSSH and Bash, installing OpenSSH is successful, however when I connect to the server via ssh ...
0
votes
0answers
27 views

If I know the inode of directory, is it possible to recover it after deleting?

More specifically, say I have a directory with lots of files in it. Suppose I know the inode of the directory. Now, if I delete the directory, is it possible to recover the files inside that directory ...
2
votes
2answers
120 views

Docker exec/run shell command nesting

A short introduction to the use case: I am using a docker container to run my go tests using go test ./.... This can be achieved easily using docker exec <container> /bin/sh -c "go test ./..."....
3
votes
2answers
4k views

GNU screen clearing on vim,less,etc. exit

I'm very new to screen but have configured my ~/.screenrc file according to various recommendations I've found on the internet. I have one issue with it though which I'm sure could be resolved very ...
0
votes
1answer
20 views

how to stop esxtop gracefully which is running in batch mode?

I am running esxtop in batch mode using the below command: esxtop –b –a –d 10 –n 2000| gzip -9c > perfData.csv.gz This is going to run for a little over 5 hrs, but I want to stop it gracefully ...
3
votes
3answers
10k views

Apply multiple .patch files

I have a directory with .patch files, generated using diff. I would like to apply all those patches using patch -p1 to another directory. But patch takes only one file, unless I cat. What would the ...
3
votes
2answers
136 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 ...