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

learn more… | top users | synonyms (1)

0
votes
2answers
52 views

Generating random passwords with shell on server deployment

I'm trying to generate random and secure passwords to my various configuration files and settings on the fly when I run my automated deployment script. I want them to be generated, shown to the user, ...
0
votes
2answers
126 views

Bash: Execute command from variable without eval

I have a problem with a script which should execute a curl command composed from the given arguments. It works if I use eval in the subshell, however, I would like to avoid that as it seems to be bad ...
-1
votes
1answer
38 views

how can i redirect run program command on different server [closed]

I have 2 server Linux server (RHEL5). Server1 is running X server where users connect to it with VNC/NX and the other one is for running programs. So users don't interrupt to each other, I want to ...
0
votes
1answer
93 views

Background job terminates when run from script, but works fine when run from bash prompt

I'm on MacOS 10.9.4. I want to put sftp to background to automatically push some files to it through named pipe later, as suggested here. It works fine when I enter commands manually from bash prompt ...
0
votes
1answer
229 views

Will this HAProxy “restart script” work as gracefully I think it will?

I put this script together from various places. What I am hoping is that it will do the following once run: Pause all "NEW" http traffic for ports 80 and 443 - just "pause" them, don't give any ...
0
votes
1answer
41 views

init.d script appears to run but dies immediately

I registered the init.d script and when I invoke this directly /etc/init.d/gae it appears to work...PID file is created but the process is no where to be seen by the time I do a ps I have googled and ...
0
votes
4answers
119 views

Redirect HTTPS traffic without changing the HOSTS file

I have a website hosted on 2 servers. The website is SSL based. I'd like to monitor (load the main page and look for a certain string) the website per server using a local Opsview. Meaning I need to ...
0
votes
1answer
89 views

Bash time check script allow 1 minute difference

I am developing a nagios/collectd check for time checking on each server. I have done bash script to get info from Collectd WSP files and check them against the nagios server time (date +%s). Collectd ...
1
vote
1answer
636 views

ip route add works manually but throws “Error: an inet prefix is expected rather than …” when run via bash script

I'm trying to run a script that should add this route to a table 11: ip route add local 10.1.3.212 dev eth1 proto kernel scope host src 10.1.3.212 table 11 If I run this command manually, it is ...
1
vote
2answers
145 views

how to prevent git from using logged in username

I would like to make it possible for any user to clone a repository without having to specify the username in the clone command. For example, say my git username is john.doe (e.g. customer ...
1
vote
1answer
188 views

cURL - download multiple files and specify output names

I have list of URLs with range in {}. I can download them with cURL in bash, but problem is output. I can use #1, but I need to have files named with different names (I have stored those names in ...
-2
votes
2answers
125 views

Cron not launching python script

Python script is not being run, all other functions are running and stand alone script runs but combined... nada. Initially it was */30 * * * * screen python ~/db_preset.py (Yes there was new line ...
33
votes
8answers
4k views

How can I run arbitrarily complex command using sudo over ssh?

I have a system that I can only log in to under my username (myuser), but I need to run commands as other user (scriptuser). So far, I have come up with the following to run the commands I need: ssh ...
0
votes
2answers
62 views

Bash Script keeps respawning after it should die

#!/bin/bash PID=$(pidof daemon) kill $PID while ps -e | grep "[d]aemon" >> /dev/null; do sleep 30 done sh -c /root/daemon This script is set on a cronjob to kill and restart this program. It ...
0
votes
0answers
13 views

pipe rrd to a new directory

I am chrooted and running out of drive space, so I mounted back to the host drive which has plenty of space but cannot seem to pipe the outputted data to my empty drive [root@localhost rra]# ls ...
1
vote
1answer
40 views

crontab truncates file path

I try to run the following command: crontab -u root /root/iss/current/node/bin/installers/nl_brandless_selector_full_hd/nl_brandless_selector_full_hd_cron_file But I got an error like this: ...
0
votes
0answers
27 views

different interactive and non-interactive shells

A user account has it's shell defined in passwd file as bash. I would like to change this user account's shell to tcsh for non-interactive jobs (like ssh ), but keep interactive shell to bash. Is ...
1
vote
2answers
221 views

Linux/Bash: Test if my server is opened to the Internet programmatically/via CLI [closed]

RHEL 6 and Bash. It would be easy if I had a remote server to just run nmap from, or even curl/wget, but I only have access to servers on our side of the firewall. I know I can manually check ...
0
votes
1answer
775 views

CentOS 6.5 proxy bypass/no_proxy not working

I am running CentOS 6.5 on my desktop. I've set the Network Proxy using the network proxy application provided under Preferences. I've also set the following exceptions: ...
0
votes
2answers
115 views

Run Bash Script Another Server

I want to run command one by one, for change the names of the directories on the server. When I run script, directories renamed in server 1. But, directories are not found in server 2. What the ...
-1
votes
3answers
149 views

Can't pipe echo to netcat?

I have the following command: echo 'HTTP/1.1 200 OK\r\n' | nc -l -p 8000 -c and when I curl localhost:8000 I am not seeing HTTP/1.1 200 .. being printed. I am on mac os x with netcat 0.7.1 Any ...
1
vote
2answers
149 views

Kill all currently running cron jobs

For some reason my cron job scripts aren't exiting cleanly and they're backing up my server. There are currently a couple hundred processes running for one of my users. I can use the following command ...
1
vote
2answers
86 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 ...
-2
votes
1answer
304 views

Bash Script to Compress / Transfer / Remove Log Files [closed]

I am currently using chronolog to set log file names for Apache with date. They are in the following format: /WEB/LOGS/APACHE_ACCESS_YYYY-MM-DD.log /WEB/LOGS/APACHE_ERROR_YYYY-MM-DD.log I would ...
-2
votes
1answer
89 views

Ubuntu Server running Plesk subversion command only accessible to root user

I have a VPS through myhosting.com the VPS is running Ubuntu 12.04.5 LTS with Plesk 12.x when I log into my VPS with the root user and do svn help I get the standard reply telling me the basics of the ...
3
votes
2answers
227 views

Bash convert character in variable

I am writing a collectd nagios custom check script in bash. The problem I am having is that nagios shows hostnames as host.name.domain but collectd holds WSP files as host_name_domain. My question is ...
0
votes
2answers
41 views

Start reading a file's content from line N using BASH

Suppose I have the file temp.txt with the following content: 1 2 3 4 5 6 How would you read the file's content starting from line number 3 using BASH so that the output would be like this: 3 4 5 6 ...
2
votes
2answers
105 views

How to get dig +short to return something when there is no answer?

The behavior of dig +short is to return nothing (null) when running a query that returns no answer (nothing to do with timeout, just an empty answer). This is ok when running a query by itself, but ...
-2
votes
1answer
48 views

Make 'less' behave like 'tail -f' [duplicate]

tail -f does what it's meant to do pretty well, but it's rather limited when some more control is needed, i.e. when stopping/resuming text would be useful. Would it be possible to use less instead of ...
15
votes
5answers
2k views

Piping wget output to /dev/null in cron

I am running the following command every 5 minutes in my crontab to keep Phusion Passenger alive. */5 * * * * wget mysite.com > /dev/null 2>&1 When I run this it performs a wget on the ...
-2
votes
1answer
119 views

Is the Datadog install script safe to run? [closed]

I have a production server (CentOS 6, Apache, Nginx, MySQL, PHP, wordpress). I want to see some metrics (e.g., load bandwidth, RAM, CPU and so on). I chose a Datadog for this task. The instructions ...
2
votes
2answers
404 views

How to bypass sudo

I am trying to script a non-interactive install of Meteor (JS Framework) and part of the script prompts for sudo . I cant seem to get past it w/ my scripting skills. The install is : curl ...
2
votes
2answers
664 views

Can I use rsync to create a list of only changed files?

I am using rsync in a bash script to keep files in sync between a few servers and a NAS. One issue I have run into is trying to generate a list of the files that have changed from the during the ...
3
votes
1answer
43 views

In tar how can I exclude dir contents but leave empty dir

I want to create a tar file excluding certains folders who have many sub-folders and files, but leaving only the main folders that's being excluded. Explaining: -project |-dir1 |-dir2 |-cache ...
-6
votes
1answer
62 views

Get rid of the ubuntu thing that suggests what packages you should install [closed]

I'm finding myself in the unfortunate place of using Ubuntu as a server OS and its tendency to suggest what packages I should install and how to install them when a program I enter in the shell isn't ...
-5
votes
2answers
53 views

Bash Script that downloads a file and checks the value if 1 or 0 [closed]

I need a Bash Script for Debian which downloads a file, that file containts 1 or 0, 1 when the services is running, 0 when not. So how can I check if the file contains 1 or 0?
3
votes
1answer
78 views

a2ensite through shell script

I created a small script to add websites on my server and it looks like this: #!/bin/bash echo "<VirtualHost *:80> ServerAdmin admin@example.com ServerName $1 ServerAlias www.$1 ...
0
votes
1answer
129 views

Where is this bash shell alias being configured?

While logged in as root onto a CentOS 6.5 system, I run ># alias alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias ...
-1
votes
2answers
103 views

Delete all files except the newest of each day

I have dump directory that is filled at the rate of one file per 4 hours. I wish to keep all files for a week then delete all except the newest of each day. Bash is preferred though other solution ...
2
votes
4answers
284 views

Run local script over ssh

silent ssh is setup from server A to server B (and some 500 other servers) I have written a script on server A (shell and perl) that I want to execute via ssh on server B (and the other 500 servers). ...
0
votes
1answer
53 views

Modify the command line that gets saved to history / .bash_history in Linux

When commands are saved to history in Linux, is there some way to prepend the command line in the history with the remote SSH IP address and process ID so that it's easy to group commands from the ...
0
votes
1answer
187 views

run multiple instance of same php script from bash

I am running a cron job to execute a php file multiple times per minute like this * * * * * /usr/bin/php /var/www/html/myFile.php >> /var/www/html/cronlog 2> /dev/null * * * * * ...
1
vote
2answers
59 views

I need to augment my output to include cat-ing a file in this Bash script

I have a script querying a remote server based on user input and looks for the last modified date of a file. It works, however, contained in the file is a string that I need to have displayed as well ...
0
votes
1answer
50 views

How to add a line to a file within a specific section by using a bash script?

I'm writing a bash script which will eventually automate user configuration for Apache. I have this part of the apache configuration (httpd.conf): NameVirtualHost X.X.X.X:80 <VirtualHost *:80> ...
0
votes
1answer
125 views

How to delete all ufw rules for a certain port?

I am using ansible to configure ufw on my DB servers to only let accept connections from certain servers connection to a specific port (lets say 1234). When a server that used to have access is taken ...
1
vote
2answers
396 views

Systemd exits from bash scripts that execute commands that result in failure, instead of continuing

I'm trying to get a script that pushes up my system log on CoreOS to logentries. To compensate for the fact that instances don't have internet connectivity right away when being spun up on AWS I've ...
0
votes
2answers
607 views

Can't run AWS CLI from CRON (credentials)

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without ...
1
vote
1answer
116 views

How do I properly escape an rsync exclude pattern used in a bash script?

Script: #!/bin/bash site=$1 remote_host=$2 new_site=${3:-$1} cmd="rsync -rlpuvz -e ssh /www/$site/ $remote_host:/www/$new_site --force --delete --exclude=\"site/web_sitemap_*.xml.gz\"" echo $cmd ...
3
votes
8answers
166 views

list linux partition names only in bash

df on linux lists the following stats on partitions. -bash-4.1# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 1918217320 1473337340 347440136 81% / ...
2
votes
3answers
95 views

Can I use Bash interpreter in service/daemon scripts?

I'm writing a Debian/Ubuntu service that should start on at runlevel 2-5. Most of the existing services I came accross are written using /bin/sh (Shell) interpreter while /bin/bash (Bash) offer lot ...