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

learn more… | top users | synonyms (1)

0
votes
1answer
22 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 init.d script to run Tomcat EE like "service tomee start" So I have 2 problems: 1. How I can execute command ...
1
vote
1answer
16 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
2answers
44 views

bash + how to hold shell scripts

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 ...
6
votes
2answers
281 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
26 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
24 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
40 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
29 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 ...
1
vote
0answers
43 views

How to run x instances of a script parallel? [migrated]

I have script I'd always like to run 'x' instances parallel. The code looks a like that: for A in do for B in do (script1.sh $A $B;script2.sh $A $B) & done #B done #A The scripts ...
2
votes
0answers
38 views

How prevent users from running commands via dot slash for a directory? [migrated]

Does anyone know if it is possible to restrict execution of commands via dot slash notation for a directory? The environment is bash on Linux. For example, I have a directory /usr/local/app/bin. In ...
0
votes
1answer
20 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
33 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
0answers
19 views

How to pipe output from cat to cut [migrated]

I want to cat /proc/uptime into cut -f1 in a Bash script. I've tried; cat /proc/uptime | cut -f1 cat /proc/uptime > cut -f1 cut -f1 < cat /proc/uptime Do I need to use echo or something ...
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
30 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
32 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 ...
2
votes
0answers
24 views

Timing of ps piped to grep [migrated]

So, this isn't a problem as such, just something i'm curious about. I'm using Linux Mint MATE which is branched off Debian. If i do ps afx | grep abcdefg i get 16599 pts/3 S+ 0:00 | ...
1
vote
2answers
29 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 ...
3
votes
0answers
48 views

can't run remote ssh command without heredoc [migrated]

I can't get this command to work: user@server:~: ssh otherserver bash -ic 'source .profile; some-aliased-command' Variations I tried user@server:~: ssh -t otherserver bash -ic 'source .profile; ...
0
votes
0answers
12 views

expect: does “” (spawn_id exp70) match glob pattern [migrated]

I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match. ...
1
vote
2answers
35 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
52 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
33 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
0answers
42 views

Pipe ssh's output (stderr and stdout) to different commands [migrated]

I'm a writing script for some kind of backup involving ssh and rsync. Every time that script runs I redirect all output to a log file. To standardize the log-entries I wrote a log-function that adds a ...
0
votes
1answer
33 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 ...
1
vote
0answers
47 views

Write file from string with tabs [migrated]

UPDATE: this may be a Windows pasting to Linux issue. The issue is not just observed with cat, but also echo. However, if I vi the file and paste into it, the tabs are preserved. I have a string ...
2
votes
1answer
77 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
24 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
54 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
128 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 ...
0
votes
2answers
48 views

CentOS root user crontab for mysqldump

I am using CentOS 6.6. I am trying to set up a crontab. I made an .sh script which runs perfectly when executed manually. The command is following: mysqldump --skip-lock-tables --single-transaction ...
0
votes
0answers
35 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 ...
1
vote
0answers
37 views

Echo each shell script command with a timestamp

set -x or set -v prints every executed command. How do I get the command printed with the time when the command started executing?
0
votes
3answers
57 views

Doing a backup with mysqldump and drop it on another server (Bash)

I'm using a cron job to do backups hourly and now, I want to drop those backups on another server by default. My script is the following: mysqldump -u db_user -p db_password db_name| gzip > ...
4
votes
0answers
420 views

Inject lines to bash history [migrated]

By default bash loads lines from ~/.bash_history to history. Is it possible to add custom file to be also loaded? I want to inject file containing commands I frequently use and access them it via ...
-1
votes
0answers
18 views

What is the best way to run PHP script every 30 seconds? [duplicate]

I have kind of a special requirement that is, I'm using a Raspberry Pi 2 B device to feed some data to a mysql database in a cloud serve. So I have installed LAMP stack on raspberry pi and config my ...
3
votes
1answer
50 views

get notification when systemd-monitored service enters failed state

I need to have network messages sent when a systemd service I have crashes or is hung (i.e., enters failed state; I monitor for hung by using WatchdogSec=). I noticed that newer systemd have ...
1
vote
3answers
116 views

Create tar file on Solaris and untar the file on Linux is it right?

I want to create tar file on Solaris (Solaris 10 ) as Kit.tar and untar the Kit.tar on Linux machine ( linux red-hat 3/4/5 ) Can we be safe with that untar process on Linux machine? , I want to be ...
4
votes
1answer
120 views

Running detached screen session but without termination in the same bash

Here are already many questions like this, but every one recommends (a variant of) the following solution: screen -dmS somename bash -c "/path/to/script; bash -l" e.g. when the script ends, run an ...
2
votes
1answer
46 views

Command 'getent'

Part 1 Is getent supposed to be an executable? In my zsh setup, I can see getent is actually defined as a function $ which getent getent () { if [[ $2 = <-> ]] then grep ...
0
votes
1answer
58 views

System Information on terminal

This might come across as a silly question but is there any shell that will allow me to get the system information as the shell is active? What I mean is a shell like bash or similar that will show me ...
1
vote
0answers
42 views

socat TCP file server

I'm trying to set up a simple socat fileserver using TCP to send small files (~100KB). Here are the one-line servers and client for one file: Server: socat -u -d -d OPEN:file.dat ...
-1
votes
2answers
68 views

how to extract mysql version by bash script in centos 6

I need to extract the mysql version in a bash script on CentOS 6 for a minimum requirements check Example: # mysql -V mysql Ver 14.14 Distrib 5.5.43, for Linux (x86_64) using readline 5.1 # mysql ...
0
votes
3answers
54 views

scp remote file to local machine [duplicate]

as a part of script I'm trying to copy a file from remote site. But got an error. To me that sounds bit strange as everything sounds ok: #aaa="/path/to/some file with spaces(and brackets).txt" .... ...
0
votes
1answer
29 views

Linux detach from process after certain string

So, I have a command which starts a webserver, it goes step by step and puts output to standard output. It goes like: step 1... step 2... step 3... server up and running on port 9000 However, this ...
1
vote
2answers
63 views

Why can't I capture AWS EC2 CLI Output in Bash?

I am trying to capture the output of an aws ec2 delete-snapshot in a Bash script command but I cannot get anything to capture the output. I have tried result=$(command), result=`command` etc. but when ...
1
vote
1answer
37 views

How to start a tmux within bash right after reboot

I have created a script to run upon reboot of an Ubuntu instance. crontab -e Then added this to the script: @reboot /home/ubuntu/startup.sh This is how the script looks like: #!/bin/bash tmux ...
0
votes
1answer
23 views

Not able to restrict the user to particular directory in unix

Below are the steps I performed: I created group sftponly. Added one user named sftpusers to that group. Added Subsystem sftp internal-sftp to file /etc/ssh/sshd_config Added this line to the file ...
2
votes
1answer
35 views

how to get the desired value in bash shell from the lshw output?

I want to extract the info from lshw output where it says: -cpu product: ...... I want only the product info of this -cpu. How can I do that with awk or sed?
0
votes
2answers
104 views

Shell Script to connect to Database and execute query [closed]

#!bin/bash Query="update table_name set colume ='i' where column_name is NOT NUll" mysql -u username -p password mysql <<EOF $query; EOF The above script is not working