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

learn more… | top users | synonyms (1)

-1
votes
1answer
30 views

Bash add entry to fstab by script

I'm newbies in bash scripting and i try to write script that add entry for cifs windows share to fstab. I writed a litle script but i'm not shure if it will work fine. I haven't linux to test it Can ...
2
votes
1answer
131 views

linux + at command + how to kill the job

I use the at command in order to run the task (test script ) every one min at -f /tmp/test now +1 minute commands will be executed using /bin/tcsh job 1438153690.a at Wed Jul 29 10:08:10 2015 ...
0
votes
2answers
38 views

top command + how to verify iowait value for one hour

my target is to check iowait value that not higher than 50 from top command and if value is higher than 50 for more then one hour , then need to give alarm about this ( by script or other option ) ...
-1
votes
0answers
22 views

Why should I use a Dockerfile instead of a batch script? [migrated]

I'm new to Docker and feeling my way around. My plan is to build a typical web app using Nginx+Rails+Postgress, all of which will be in the one container. I'm not (currently) doing anything complex ...
0
votes
1answer
23 views

Pass output of an expression to the standard input of another program

I'm trying to generate some data to pass to another program, which takes the argument from standard input, and requires confirmation of that argument. How do I do this in bash? From the manual ...
0
votes
1answer
11 views

Bash find file with specific permission for group, no matter permission for user and others

Using only octal notation, I need to find file that have only read permissions for group, no matter which owner and other permission are. Which is the right command? I can't find it. Thank you.
0
votes
0answers
24 views

bash scripting and comparing 2 directories - Beginner [duplicate]

My problem is that i have to check what files are included in the $directory, then i have to make a new file with name specified by me and compare if the name doesn't already exist in this directory ( ...
1
vote
0answers
41 views

bash scripting comparing 2 things [closed]

My problem is that i have to check what files are included in the $directory, then i have to make a new file with name specified by me and compare if the name doesn't already exist in this directory ( ...
-1
votes
0answers
22 views

Command Run Differently Depending on How Logged In? [migrated]

Is there a way to have one command run differently, depending on the manner in which one is logged into the session launching it? Basically, we have a command that when run, launches vim to display ...
-3
votes
0answers
25 views

Change ip address while surf web pages

I am looking for command line browser like lynx but with --bind-address command line argument, like wget does. so i can browse the webpage with one of my ip address in server
0
votes
1answer
27 views

cron and lftp issue

I have the following scripts running on raspbian. start #!/bin/bash /root/config/commands 2>&1 > /root/log/$HOSTNAME.log commands #!/bin/bash source /root/config/variables echo TestLine ...
1
vote
4answers
28 views

find command with parameters in variable

> find /etc -name 'shells' /etc/shells # good !! > SEARCH="-name 'shells'"; find /etc $SEARCH # nothing found - bad !! Why "find" command can't take params in variable? Other commands ...
5
votes
0answers
262 views

Renaming: How to attach a word or rename multiple files [migrated]

I have multiple files in my directory. for example: eventDataLog.txt.2015-04-23-22 eventDataLog.txt.2015-04-23-23 eventDataLog.txt.2015-04-24-01 eventDataLog.txt.2015-04-24-02 ...
0
votes
1answer
24 views

find files which are not currently in use

I'm trying to archive some older files, but don't want to touch all the files which are currently in use. What's the best way to ask find to exclude "in use" files? Right now I'm working on this ...
0
votes
1answer
33 views

OpenSCAP incorrectly reporting false for RHSA-2014:1306: bash security update (Important)

I'm using the following command to test for RHSA-2014:1306 on CentOS 5.9: oscap oval eval --id oval:com.redhat.rhsa:def:20141306 com.redhat.rhsa-all.xml The result is: Definition ...
0
votes
1answer
23 views

Is there a way to prevent the Screen progarm from killing all windows?

I have a server application whose output is can be viewed through the Screen application on linux. However, I noticed when using the command-line application I noticed that this command can terminate ...
1
vote
1answer
57 views

Best way to show architecture of a specified file system?

Admitting a filesystem is installed in ~/FS/ (which is its root), how can I check its architecture without chroot? I tried with dpkg --root=~/FS/ --print-architecture but it still prints me the ...
0
votes
1answer
26 views

bash rsync is Killed by signal 2

Problem: I am trying to prevent the user to cancel the script by using ctrl + c. The following script executes completely, except rsync that insists on dying, displaying the error "Killed by signal ...
0
votes
2answers
23 views

Strange behavior of SCP through .sh file

I'm hitting a strange issue with SCP on cygwin, scp $HOME/deploy.sh user@host:/tmp works fine, files get copied to the remote system. But the same command inside a test.sh won't work. I can see ...
0
votes
2answers
42 views

rsync - How can I exclude from all instances of a file while using relative paths for each file?

I am coding a deployment script that uses rsync to sync cloned repository files with a website target directory. I am trying to allow my users the ability to place a .exclude file anywhere in their ...
0
votes
1answer
20 views

Whats the proper what to terminate a script using start-stop-daemon?

I am using a start-stop-daemon to make a INIT script for my script. I am using --make-pidfile cause my script doesnt make its own pid. I can start my script using start and pid file generates with ...
0
votes
3answers
53 views

Multiple servers Rsync into one NAS simultaneaus

Scenario: 1 NAS at our main office (Synology Cubestation CS407) 20 remote servers in various physical retail stores (1 server per store) Network between HQ and stores are in an MPLS/VPN. I have ...
0
votes
1answer
42 views

Different values in bash and Zabbix WebUI

I would like to ask you for any hint regarding following issue. I'm using external scripts for checks in Zabbix 2.2. I try to develop some script which will get timestamp of certain file on remote ...
2
votes
0answers
19 views

Bash: How to avoid variable name substitution when using auto-completion? [migrated]

I'd like Bash to stop removing variable names from paths and replacing them by their values. I tried several 'shopts' settings in various bash versions but was not successful in keeping a variable ...
-2
votes
0answers
27 views

echo text after curl command on same line [migrated]

#!/bin/bash echo "$(curl -s -I https://google.com|grep Server)" abc returns: abcer: gws and bash -x shows: ++ grep Server ++ curl -s -I https://google.com ' abco 'Server: gws abcer: gws but echo ...
0
votes
1answer
66 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
47 views

php-fpm and Nginx dynamic environment variable

FPM configration stats that you can retrieve variables from your current environment. However, on ubuntu using Nginx and PHP-FPM, I can not find a way to retrieve the variable value from the ...
1
vote
1answer
41 views

Command substitution into bash script $1 value

I have this simple script which changes permissions on my apache2 websites /var/www/html# cat permissions_setup.sh chown -R root $1 chgrp -R www-data $1 chmod -R 750 $1 chmod g+s $1 I have two .sh ...
1
vote
1answer
37 views

How do I run TomEE as a service on RHEL6?

cat /etc/passwd (last line): tomee:x:990:987::/home/tomee:/bin/false I need to make an init.d script to run Tomcat EE like service tomee start. So I have 2 problems: How I can execute command ...
1
vote
1answer
23 views

Trying to get pid from a script running as su -c

I am trying to get these scripts to work in an environment where the java application needs to run as user foobar no matter if it is started as root or foobar. So these are my modifications to the ...
2
votes
0answers
46 views

bash + how to hold shell scripts [migrated]

Is it possible to hold/stop the bash script progress without to kill the process? ( by kill command ) or other command For example this script - install_linux_pkgs.bash , will install Linux pkgs ...
7
votes
3answers
325 views

How to execute a command for each file in a deep directory structure, recursively?

I have a deep directory structure, with a large number of files (about 1M). I'd like to execute a command against each. (In my case the files are pngs which I'd like to run optipng against.) I've ...
0
votes
1answer
28 views

SSH: How to get the list of servers that autocomplete when hitting tab after ssh?

When I tab complete after typing ssh, I get a list of servers that I can ssh into. How would I get that same list with a single command? The pseudo command would be: ssh --list-available-servers ...
0
votes
2answers
49 views

Running ssh/netcat in the background

I'm trying to run a network throughput test between an OS X and a Linux host. I'd like to be able to measure the sustained throughput from the Linux host to the OS X host over time. I'd like to wrap ...
1
vote
4answers
44 views

test when directories are in sync using rsync

Is there any way to know from a bash script when a rsync command does not download anything (aka the folder is in sync)?, I've tried using the exit code, but is only different when an error happens. ...
0
votes
1answer
48 views

How to change time format to seconds in ps -p?

I wrote a rsync script which also checks for how long the process of the script has been running. This is the relevant part: time=$(ps -p $processid -o etime= | awk -F: '{print $2}') # number of ...
0
votes
1answer
29 views

ssh session stuck after some time of iddleness

I'm using fedora 19 and bash 4.2.53(1)-release If I leave an ssh connection opened for some minutes and don't do anything with it, the terminal get stuck. Here's netstat's output: tcp 0 ...
-1
votes
1answer
36 views

How can I visualize a file removing every type of comment if a file (including /* */)? [closed]

I have this small script to visualize config files without the comment lines: cat $1 | grep -Ev '[:blank]*#|^[:blank]*$' | pygmentize -g but it still shows some comments in some files when they have ...
0
votes
2answers
24 views

How to handle passwords in a script: in-memory VS on-file

I have a script that runs on a VPS in a cheap cloud provider. The scenario is: I trust my provider, but I prefer to make his life hard if he ever wants to steal my key. All the interested folders in ...
1
vote
0answers
37 views

Find pid of long running bash script [closed]

I find myself in an interesting situation I can't think of an easy solution for. I started a long-running shell script that I can't stop or let die. I forgot to screen/tmux this script out or to ...
1
vote
1answer
38 views

unexpected end of file error in script file

#!/bin/sh # Host = ############### Port = #### email_id="##################" email_sub="######" # if ping -q -c 5 $Host >/dev/null then result_host="Successful" else result_host="Not ...
1
vote
2answers
38 views

Bash script rsync --include-from fail

I have writted a bash script to backup folders and files from a machine to our backup server. My goal is to exclude all the files older than 6 months from this weekly backup. To do that, I used a find ...
1
vote
2answers
71 views

Automate pg_dump in a bash script

I am re-learning bash after years of not using it very much and need to figure out a way to automate pg_dump of a single database to a directory. Currently I manually ssh into the box, su to postgres ...
0
votes
2answers
86 views

Running a bash script via cronjob to restart a service

First of all. I don't know anything about bash scripting. second this is a very big problem on my side, and I don't have any idea what to do. Currently, I have this website. which was written in php. ...
0
votes
1answer
59 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 ...
0
votes
1answer
49 views

sudo su not working correctly inside a bash script [duplicate]

I have a script to setup a machine that need to change to another user. Unfortunately, I get a "permission denied" after the su command. #!/bin/bash # script executed from /home/foo/ touch hi_foo cd ...
2
votes
1answer
84 views

Strange filename encoding

I have a strange issue regarding a filename. Summary of the situation is: [username@xxx tmp]$ ll -rw-r--r--. 1 xxx xxx 42694 8. Jun 19:56 12287_KKL_Messegerät_EF_30.1.pdf -rw-r--r--. 1 xxx xxx 42694 ...
0
votes
1answer
26 views

Find difference in file encoding

I am sending email from the cmd with msmtp for that I do cat > test1 << EOF >From: "Tester" >test >EOF cat test1 | msmtp email@mail.com This works while: echo -e 'From: ...
0
votes
1answer
67 views

How to import postgresql file on Linux with space in path?

If I try to import an sql script with a space in path, the file is not found. mypsqluser=> \i /home/markus/Documents/Projekte/My App/Installation/server_sql_script.sql ...
1
vote
5answers
144 views

Find IPv4 broadcast address of a device

I need to determine the IPv4 broadcast address of a device (if any) with a shell script. If there are several, pick one (e.g. first as ordered by /sbin/ip). I have a solution, but i do not like it ...