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

learn more… | top users | synonyms (1)

-1
votes
1answer
25 views

Create user account on many servers

I have a users.txt with the following content: ip1 user1 password1 ip2 user2 password2 .... ipN userN passwordN I want to create one user on each of these servers. I want to use this script on each ...
12
votes
6answers
42k views

How can I edit the welcome message when ssh start?

I have a vps for my website hosting. It is running a ubuntu server. Every time I logged in my server by ssh, it displays a lengthy welcome message in my terminal. Linux node61.buyvm.net ...
0
votes
0answers
8 views

Load OpenMPI module for Apache httpd

How can I tell Apache httpd which version of MPI to use? I'm trying to run a Django web application under Apache httpd, and some of our pages make MPI calls with mpi4py. The problem is that I get an ...
0
votes
1answer
967 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" ...
6
votes
3answers
6k views

iftop - how to generate text file with its output?

iftop is great tool to view almost live bandwidth usage distinguished by source-ip source-port destination-ip destination port. I'm using it to see which client's ip is using most bandwidth. Now I ...
2
votes
1answer
1k views

Linux- Permission denied?

I'm installing Neo4j server as a linux service, but when I install it, I get the following message: /sbin/insserv: Permission denied What is this? What should I do? I'm running everything with ...
-2
votes
0answers
14 views

Converting a hobbit/xymon bash script to python [on hold]

I have this bash line that I want to convert to python. $BBHOME/bin/bbhostgrep $TESTNAME | while read IP HOSTNAME OTHER; do How would I convert this to python? TIA usaims
6
votes
3answers
5k views

How do I exclude a folder when performing file operations i.e. cp, mv, rm and chown etc. in Linux

How do you exclude a folder when performing file operations i.e. cp etc. I would currently use the wild card * to apply file operation to all, but I need to exclude one single folder. The command ...
0
votes
0answers
30 views

SSH issues: keyfile and host file not working as expected

When I login to server with a key ssh -i /home/me/.ssh/id_rsa server everything goes without glitch. The key is authorized on the server. However if I try to do same from a shell script, I get a ...
1
vote
2answers
39 views

Disable all outbound network

I cannot seem to find any information on how to completely disable all networking. Essentially I want to flip the switch for any outbound or inbound networking. Like the wifi button on my computer, ...
-2
votes
0answers
24 views

Linux have a script download a file on your computer [closed]

I am setting up a special kind of script for a project that I am working on. I'd like my script, when executed, to take a file that is on the server and put it on the computer. I have no idea how I ...
0
votes
1answer
40 views

Script to Push Files

Script to Push Files Hey Guys, Thanks for always being helpful, I have another issue that I need a little insight on how to fix. See the below script I have and the error I get. I don't understand ...
-5
votes
0answers
18 views

How to execute script when email recieves in sendmail? [closed]

Hello I am new to sendmail. I configure it for sending mail using sendmail. But how can I execute bash script on receiving of any messages in sendmail. Actually I want to download attachments and save ...
1
vote
2answers
883 views

Meaning of killall -0

I see from many place the follow command is used to check if a process exists, e.g. killall -0 nginx But from the documentation I can't see anything related to this argument, can anyone explain?
5
votes
5answers
2k views

Send message to IRC channel from bash

I have installed ircd-hybrid on my Ubuntu Server (192.168.1.2, example.com). We use #teamchannel to communicate inside the team. The question is: how can I send some short message from example.com to ...
2
votes
4answers
1k views

How to get the mount point of flash drive by using uuid?

I am beginner in ubuntu linux and i need to write simple bash script, that can identify necessary flash drive(which contains only one vfat partition) using uuid of this partition, and get the mount ...
1
vote
1answer
62 views

New to bash - “Unexpected end of file”

I'm trying to set up a simple bash script to check and see if an error message appears in a log, if that error message "reset adapter" appears in that log the server is supposed to email us. Whenever ...
0
votes
0answers
47 views

How best to maintain a recent bash version on amazon linux?

I require Bash 4.2 or higher. Amazon Linux default repositories only provide Bash 4.1. I have done some searches and can not find a yum repository for recent versions of Bash. I don't want to compile ...
2
votes
3answers
130 views

One line script to check and react to memory usage

I'd like to have one line of shell/bash that does something along these lines: test "`free | grep | awk | whatever` -gt 80" && any_command Where the total percentage of ram being used by ...
12
votes
3answers
9k views

Using bash, how can i find out the average, max and min from a list of numbers?

I have a series piped greps, awks and seds which produce a list of numbers, one on each line. Something like this: 1.13 3.59 1.23 How can i pipe this to something which will output the average, ...
0
votes
1answer
84 views

Cron occasionally fails with “grandchild #X failed with exit status 3”

I have cron jobs and every now and then they fail. Just after log message that the command has started, there is grandchild #X failed with exit status 3 message. On the next run scripts finishes ...
0
votes
1answer
39 views

Efficient way to parse Apache Access Log for CMS logins

I've been working on a way to parse large multiple access logs (sometimes in double digit GB in size) for CMSs. Right now I just need WordPress and Joomla, but I know the types will grow over time. ...
4
votes
1answer
35 views

How would you add a share to smb.conf via a script?

I'd like to script adding a share to a smb.conf file. My current script just appends it to the end of the file, but that's not ideal. I'd rather have something that will add a new share if it doesn't ...
0
votes
1answer
33 views

Executing local function code on a remote server

I am updating about 20 bash scripts that perform various server-side operational tasks, checking status / sending reports etc. On some environments these scripts will run locally, on others they need ...
-2
votes
2answers
49 views

How to insert text from a file into another in bash [closed]

The content in fileA is: Here’s the ip list. ip: 2.2.3.4 ip: 2.2.3.5 ip: 2.2.3.6 ip: 2.2.3.7 The content is fileB is ip: 1.2.3.4 ip: 1.2.3.5 ip: 1.2.3.6 ip: 1.2.3.7 How to use sed command or ...
0
votes
1answer
45 views

How can I return a specific exit code on the Linux command line?

I've got a program that controls a long-running process which runs over ssh on a remote machine. Frequently, I'll get disconnected in the middle of the process, so I've changed the invocation from ...
12
votes
4answers
15k views

Multi-select menu in bash script

I'm a bash newbie but I would like to create a script in which I'd like to allow the user to select multiple options from a list of options. Essentially what I would like is something similar to the ...
17
votes
7answers
16k views

How do I run a local bash script on remote machines via ssh?

I am looking for a way to push configuration from one central machine to several remote machines without the need to install anything on the remote machines. The aim is to do something like you ...
2
votes
2answers
18 views

Is it possible to determine if a job is being started as an at job (kicked off via atd/cron)?

Is there a way to identify a script is being run as an at job instead of interactively from the shell by a user? Some of our scripts have a guard to check if they're running in screen by checking ...
5
votes
3answers
2k views

How to interrupt stuck bash tab completion?

Case: A Windows share mounted using samba over a flaky VPN connection (sometimes very slow, sometimes it drops) When doing tab-completion on filenames, my bash shell can freeze up if the VPN is slow ...
0
votes
0answers
29 views

bash NOT reading .bashrc on RHEL 7 [migrated]

machine A --RHEL 7 and updated. machine B -- RHEL 6 and updated. If I do this on A (RHEL 7) ssh B I get in, like I should, but my .bashrc has NOT been run. This is new behavior to me. I want ...
-2
votes
0answers
37 views

How can I capture two columns of ls output in a bash script [migrated]

I want to create a script to delete any directories with numeric groups. What I have so far captures and analyzes the group: #!/bin/bash re='^[0-9]+$' for x in `/usr/bin/ls -l /var/indexes | sort ...
2
votes
8answers
4k views

How to cut extension from pathname with basic unix tools

I need to gather a list of files and put this in a textfile. However, the files should not include their extension. The command I have now without removing file extensions: ls -1 /a/dir/*/dir/* > ...
5
votes
6answers
11k views

What is a recommended way to patch the Shellshock Bash bug on an unsupported Ubuntu server?

I maintain an out-of-support Ubuntu 12.10 (Quantal Quetzal) server (don't ask me why, please), and we need to patch the Shellshock Bash security bug. As upgrades are not available anymore, what ...
9
votes
4answers
11k views

Can not update Bash on Debian 6.0 (Squeeze)

I can not update Bash on a Debian 6.0 (Squeeze) server to get rid of the discovered vulnerability: bash --version GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu) apt-get update apt-get ...
90
votes
9answers
30k views

Keeping a linux process running after I logout

I'm connecting to a Linux machine through SSH, and I'm trying to run a heavy bash script that makes filesystem operations. It's expected to keep running for hours, but I cannot leave the SSH session ...
2
votes
6answers
11k views

FTP uploading in BASH script

I need to upload the entire content of a directory /home/test to my ftp server, in a specific folder. I will then schedule the script hourly via cron. Any examples? NB. consider that I'm on a Netgear ...
0
votes
1answer
28 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 = ...
69
votes
9answers
93k views

How do I get current Unix time in milliseconds using bash?

How do I get the current Unix time in milliseconds (i.e number of milliseconds since Unix epoch January 1 1970)?
1
vote
2answers
14k views

bash script - spawn, send, interact - commands not found error

I my shell script, I am trying to remove password prompt for scp command (as given in http://stackoverflow.com/questions/459182/using-expect-to-pass-a-password-to-ssh/459225#459225) and this is what I ...
0
votes
1answer
131 views

Updating a Vyatta 6.6 box for Shellshock

A client has a few Vyatta installations that they're eventually wanting to replace with VyOS. In the interim, they're running Vyatta 6.6 (last version prior to the sale to Brocade). It's an internal ...
0
votes
4answers
7k views

remove line break using AWK

I am facing some problem regarding my bash script. Below is my bash code : #!/bin/bash cd /root/Msgs/TESTNEW/new file=myfile.txt var1=$(awk '(NR==30){print $2}' $file) var2=$(awk 'NR>=38 ...
1
vote
3answers
3k views

ulimit -n not changing - values limits.conf has no effect

I am trying to raise the open file descriptor maximum for all users on an ubuntu machine. This question is somewhat of a follow up to this question. open file descriptor limits.conf setting ...
3
votes
3answers
119 views

Setting up FQDN in sendmail [closed]

In this blog post he suggests echo '127.0.0.1 localhost EXAMPLE.my_domain localhost.localdomain EXAMPLE' >> /etc/hosts but ends the post with But this is a less desirable approach ...
4
votes
3answers
5k views

Regex for sed to grab multiple lines or a better way?

I'm creating a script that connects to a server and dumps the output to a tempfile. I want to use sed in the script to grab specific information from the temp file. The output would always have the 80 ...
-3
votes
1answer
27 views

Display only some of the lines of the lsof command [closed]

I am trying to create a bash script for displaying only certain lines of the lsof command. I have figured out that the lsof command itself lists information in the form of columns which show info ...
0
votes
0answers
45 views

How to print a range of IP addresses with Linux seq command [migrated]

How can I print a range of ip addresses on linux command line using the "seq" command? For eg: I need seq to print a range of ip from 10.0.0.1 to 10.0.0.23 . Seems like the period in between the ...
-2
votes
1answer
45 views

How to open sftp connection and execute sftp command in the same shell command [closed]

Is there any possibility for opening sftp connection to remote server and execute sftp command in same line from shell. Something like this: sftp user@example.com && put /tmp/test.txt /tmp/ ...
-3
votes
1answer
41 views

How can I execute sibling scripts outside the directory? [closed]

$ ls -l bin/ $ ls bin/ startup.sh shutdown.sh I wrote a script named restart.sh inside the bin/ looks like #!/bin/sh sh ./shutdown.sh sh ./startup.sh Now the bin/ directory looks like this. $ ls ...
0
votes
1answer
32 views

NUT UPS: stop specific service on power failure

Does anybody know how to stop a service when there is a power failure using NUT? I made a custom script like this, the problem is that the script user (NUT) does not have root permissions to stop the ...