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

learn more… | top users | synonyms (1)

2
votes
0answers
13 views

openldap user can't login when using tcsh

I would appreciate any help in the following problem: I have an openladp (2.3.39) server (Fedora 8) which authenticates users from other ldap clients (various versions of Fedora). On my attempt to ...
8
votes
3answers
149 views

Bash one-liner to atomically create a file if it doesn't exist

I want a Bash one-liner that atomically creates a file if it doesn't exist. That means essentially "if file doesn't exist, create it" but ensuring that no one else manages to create the file in the ...
1
vote
3answers
23 views

Calculating the percentage of the total available memory on linux as an integer in bash

Here is a bash script that is calculating 80% of the total RAM available as an integer on a Linux box: server_ram_mb=$(awk '/MemTotal/ {printf( "%.2f\n", $2 / 1024)}' /proc/meminfo) echo ...
1
vote
1answer
34 views

ZFS Send Script works when run manually but not in Cron (Already tried common solutions)

Script on sending end is as follows: #!/bin/sh #Variables bigdata=vid-zfs-live/bigdata today=`gdate +%m-%d-%y` yesterday=`gdate -d'yesterday' +%m-%d-%y` #Actions zfs snapshot -r ...
-1
votes
2answers
31 views

Script to delete older files and copy what is left

We have a server that runs an application that is used internally. The application has a utility that creates its own backups every 24 hours. Backups are stored in: ...
-2
votes
0answers
24 views

how to set date from the main centos server to all remote server using bash scripts

h! Actually i want to set date from the main centos server to all remote servers simultaneously and no any date on remote server might be different with the help of bash script. In short getting ...
2
votes
1answer
49 views

How can I set the root password in a docker container from a script?

I have a script that runs on the host and creates/starts/stops a docker container. I'd like the script to change the password of the root user within the container. Since the container is an ssh ...
0
votes
0answers
4 views

How to prevent malicious injection in argument to php “exec” (webhook -> bash script) [migrated]

I've written a webhook to integrate into chat (slack / mattermost api). The simplest way to get it up and running was a quick php script, which looks like this: <?php $token = $_POST["token"]; ...
-2
votes
1answer
36 views

SAVE IP ROUTE RULES AFTER REBOOT

I have two internet connections from two different ISPs and I need to balance & failover the traffic originating to and from my network between the two ISPs. My settings: FIRST ISP (eth0): ...
1
vote
2answers
29 views

How to run ./configure from a different folder?

I'm writing an ansible playbook which is supposed to compile from source some tool and install it. While checking my playbook, I've tried running the relevant commands manually to check their output. ...
3
votes
2answers
71 views

Allowing PHP to run specific bash script with root permissions

I have a php script calling a bash script like this: <?php $result = exec('sudo /bin/bash /var/www/my_bash_script.sh /var/www/vhosts/testsite/htdocs/'); var_dump($result); ?> This is ...
1
vote
0answers
14 views

Why my profile looks for /usr/local/etc/profile.global (NIS)

My Ubuntu ID is manged by NIS/yellowpage. For some reason, when I log in, I'm getting this message. cat@local:~$ ssh catserver cat@catserver's password: Welcome to Ubuntu 15.10 (GNU/Linux ...
0
votes
1answer
30 views

Log all bash actions with multiple scripts

Using the command below, I can log all actions that happened inside that script. bash -x script.sh Sadly, the script calls another script, which does not have the -x setting active then, i.e. the ...
2
votes
2answers
23 views

how to match a whitespace in a bash variable

According to the man page, the string to the right of =~ is treated as an extended regular expression. I've tried the following things to match an "ok" surrounded by whitespace on either side, but ...
1
vote
2answers
48 views

pacemaker corosynce lsb resource script( Sybase Database ASE Server and Backup Server)

I'm trying to create a lsb resource with pcs on rhel7.2 The "sybase" script is about Sybase Database ASE Server and Backup Server Startup & Stop & Restart $ status script Before ...
18
votes
2answers
2k views

Will Ansible prevent the execution of 'rm -rf /' in a shell script

This is based upon this hoax question here. The problem described is having a bash script which contains something to the effect of: rm -rf {pattern1}/{pattern2} ...which if both patterns include ...
2
votes
1answer
35 views

unix utility to limit the number of bytes placed into a bash variable

Is there a unix/linux utility, perhaps a shell builtin or an external command, that will limit the number of bytes placed into a bash variable? For example, I want to make sure STRING gets at most ...
5
votes
2answers
120 views

Cat, Grep, Redirect Output… Blank File?

I just ran cat /opt/webapplications/Word/readme.log | grep -v 'Apple' and I got the output on the cli that I was expecting, which was all the lines in readme.log that did not contain 'Apple'... ...
0
votes
0answers
4 views

How can a command in a pipe read from a keyboard? [migrated]

I randomly tried to execute the following command in bash1 cat /some/file | ssh user@machine 'cat >/destination/file There are no keys installed on the remote machine, so the only way to ...
1
vote
1answer
35 views

Ansible & rbash

I want to manage a bunch of devices running /bin/rbash as the default shell with Ansible. The problem is that Ansible always try to execute a list of commands that rbash doesn't like at all: umask ...
0
votes
0answers
23 views

Cacti poller runs but not full script

I'm using Cacti and the poller calls a bash script to get some data. At the end of this script I have a logical test and then an email is sent if true. The issue I have is when the poller is running ...
0
votes
0answers
19 views

“-bash: fork: retry: …” on SSH connection

When I'm connecting via ssh to my useraccount of my server, I'm getting the following error: -bash: fork: retry: No child processes -bash: fork: Resource temporarily unavailable Does anyone ...
0
votes
3answers
45 views

Bash if condition to check if a ubuntu package needs an upgrade?

I need a bash line to check if a ubuntu package needs an upgrade or not. For example, I want to check if the package 'firefox' needs an upgrade using dpkg or apt-get commands. Hypthetical Example: ...
0
votes
2answers
157 views

Unable to run a python3 script in CentOs7 [with python2.7] via cronjob

I have been trying to deal with this strage problem all morning. I have a simple crawler.py file, which contans a code that can only run under python3 to be exact under python3.3 evenrionment Now, ...
2
votes
2answers
52 views

printing user of subshell obtaining root via su -

Can I print the username which is obtaining root access via su - on the root console upon obtaining root? user1$ su - password: obtained root via user1 #
0
votes
0answers
8 views

su rails session mysteriously closes by itself

I need help troubleshooting a strange problem. When I ssh into a server I have and do an su rails from root user the session closes by itself: root@ubuntu-server:/4# su rails rails@ubuntu-server:/4$ ...
1
vote
1answer
42 views

ansible custom facts returning string not array

I have a custom fact for my servers to retrieve customer data. This works fine on the machine and returning valid json. I can write the output to another facts-file and this works perfectly fine too. ...
1
vote
0answers
35 views

Linux ramdisk transfer files on reboot [closed]

I've created a tmpfs ramdisk, which is mounted at boot through /etc/fstab. The ramdisk should be used to serve content to an apache web server running on the machine. Is there a simple way to ...
-1
votes
2answers
28 views

Job control: How to kill a sudo job using the job id

If I run jobs with sudo I can't kill %1 them (Operation not permitted). My first thought was to use sudo kill %1 instead, but that of course doesn't work either because it won't use the bash builtin ...
0
votes
1answer
47 views

Installing a software in multiple linux machines using shell scripting in one machine

I will login to one Linux instance using ssh - putty and my goal is to install a software (for ex: I need to download oracle and install it) on 5 Linux machines with one shell script when I run that ...
1
vote
0answers
23 views

Deleting files from Remote FTP-Server older than X days (only ftp, curl or lftp) [duplicate]

I have similar situation descibed here: Deleting files from Remote FTP-Server older than x days and I see this is not answered fully yet so I would like to register the new one. My files are having a ...
1
vote
1answer
43 views

nginx - How often was accessed to specific file or path? [closed]

I'm looking for a command/line to get the information how often was a specific file/path accessed from the web-server. (source: default access-log from nignx) It should check all logs (current and ...
1
vote
2answers
39 views

Script to combine data from one file to another [closed]

I have a file containing folders name/value pairs: peter:/home/peter/ max:/home/max-lucas/ judith:/home/judith/documents/ I have another file containing files name/value pairs, with the same ...
-1
votes
1answer
32 views

Cronjob doesn't run. Similar cronjob does run. Issue with Env Vars??? Fedora involved. psql involved [duplicate]

I have cronjobs like so * * * * * /usr/bin/psql -U usename dbname -c "select usename, now(), pg_terminate_backend(pid) from pg_stat_activity where state like 'idle%' and (now() - query_start) > ...
12
votes
4answers
1k views

How do I recall a specific command from command history, without executing it

For example, in bash I can type !xyz which will run the last command I typed beginning with xyz. How can I bring up the last command I typed beginning with xyz but without executing it? e.g so I can ...
0
votes
1answer
25 views

Variables lost outside loop

I am trying to backup my DB using mysqldump, while ignoring some tables defined in a variable, but while looping, I got the last table name, it was overridden, how can I store tables inside a variable ...
0
votes
1answer
24 views

Convert $no_proxy to gsettings ignore-hosts

In order to use Chrome in Ubuntu and have it respect some hosts in $no_proxy, I need to set those comma-separated values with gsettings set org.gnome.system.proxy ignore-hosts <no-proxy> where ...
0
votes
2answers
56 views

How to autocomplete long file names in terminal

If I have in current directory a file with a long name starting with "build" I can write in console "build", press Tab and autocomplete type full filename for me. However if I have multiple files ...
2
votes
2answers
63 views

Command prompt taking too long to appear after ssh connection

I have a server that is acting really weird and hopefully you will help me find out what is happening. Here are the facts: The server has 2 users: root and myuser The server accepts only ssh ...
-1
votes
1answer
44 views

create an array of dates in bash scripts and match it with current date [duplicate]

Actually i want to create an array of dates and compare it to the today date if it match with the current date then execute test.sh file otherwise exit the loop in bash script. I did like this... ...
-3
votes
2answers
47 views

How to compare today's date against an array of dates [closed]

I want to create an array of dates and compare it to today's date if it matches then execute test.sh file otherwise exit the loop in bash script. I have this so far: #!/bin/bash now=$(date +%Y-%m-%d) ...
0
votes
1answer
42 views

remote SSH command works but not when used in bash script

I am trying to stop tomcat on a remote server using a bash script. Here is the function: function stop_remote_tomcat () { CURRENT_SERVER=$1 CURRENT_USER=$2 CURRENT_PEM_FILE=$3 ...
-4
votes
2answers
43 views

execute bash script on last thursday of every month [closed]

Actually i have a bash script file and i want to execute it on the last thursday of every month please help me to find out the proper solution of that problem using bash scripting.
0
votes
1answer
34 views

How to combine lsof stat and ps to get more info in one line bash command

I can use lsof to get top open files stat for processes, as below: $ lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr | head -n 5 17955 11945 10282 2786 5980 32152 1920 27803 1786 32107 ...
0
votes
1answer
105 views

Expect script too fast: add a sleep between each line read from a file

I am trying to automate switch commands. It's almost all good, but when the expect script reads each line from the file containing my switch commands (listed line by line), the switch seems to stop ...
0
votes
0answers
42 views

Python script to delete HPSA RHEL software policy items(rpms)

I'm looking to script the deletion of HPSA software policy items (RHEL RPMs) from HP Server Automation server. In our environment we have "HP Server Automation 10.22", using rhn_import command we ...
1
vote
1answer
22 views

Run command in screen when LSB initscript stopped

I'm trying to get a Bukkit server to run inside a screen as a service, started from an LSB script but I cant get it to stop correctly. What I essentially want it to do is reattach the screen and send ...
0
votes
2answers
109 views

How to zip files with a size limit?

I have a script that zip files from a folder. I want to make sure that the zipped file is not more than 10 MB. If the size is more than 10MB, it should create another ZIP file. Is there any command ...
2
votes
2answers
182 views

Allowing httpd to run a bash script in /usr/bin/

Migrating a system from CentOS6 to RHEL7 with SELinux running Enforced. A php script makes a call to /usr/bin/processdata.sh to generate some data behind the scenes. This worked fine with the old ...
2
votes
3answers
43 views

Bash for loops and hostnames and how to generate them

Why doesn't this work? NODE_ROOT=node0 INFRA_DOMAIN=example.com for host in $NODE_ROOT{1..3}.$INFRA_DOMAIN; do echo $host; done I'm expecting: node01.example.com node02.example.com ...