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

learn more… | top users | synonyms (1)

0
votes
0answers
10 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 ...
1
vote
1answer
18 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
1answer
91 views

Mass disable customers in OTRS

The problem is about OTRS customers. I can't use an external customer backend, so I want to update the customer DB via CSV files. I already wrote a script to add new Customers via ...
2
votes
5answers
2k 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
2answers
27 views

Shell Script to connect to Database and execute query [on hold]

#!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
9
votes
0answers
446 views

Why is my Bash script returning a syntax error? [migrated]

I am writing a script which loops into recent files in a folder and executes a command... #!/bin/bash cd /home/Downloads recent_files = ($(ls -t | head -20)) for file in "${recent_files[@]}" do ...
2
votes
5answers
11k views

ssh to multiple hosts and sudo multiple commands

I need to loop through and ssh to multiple hosts and run a series of commands on each. something like: for i in $(jot -w '%02.0f' 14 1) >do ssh user@host$i sudo -i "command1; command2; command3" ...
1
vote
1answer
958 views

JBoss EAP 6.2 on RHEL 6: ./bin/init.d/jboss-as-standalone.sh hangs while calling via SSH

I'm using jboss-as-standalone.sh to manage JBoss EAP standalone as a service. I can start/stop the service with "service jboss-as-standalone.sh start/stop" while I'm on a terminal. But I would like ...
0
votes
1answer
176 views

Escaping special characters while sourcing file in bash

I've written a script that sources a bash shell fragment. The shell fragment is supposed to be a kind of configuration file, basically it's a bunch of bash variable. The issue here is when some of ...
-2
votes
1answer
26 views

Uphold variable life in Bash loop [on hold]

I am trying to find the number of files with executable permission by the owner. I am doing this but giving me error cmd> ls -la /myScript.sh myScript.sh is the following z=0 while read line do ...
1
vote
1answer
974 views

Problems in monitoring file age with nagios (command substitution in filename)

In my current nagios installation I check for the existence of a remote backup through NRPE. In particular, my remote nrpe.cfg (on a Ubuntu 8.x) is: ...
0
votes
1answer
49 views

Add cronjob with bash script - No crontab for root [duplicate]

I have a deployment script and in it I'm trying to add a cron job. This is the code I am using which I found on stackoverflow. I'm running debian 8. # ADD CRON crontab -l > mycron echo "10 * * * * ...
0
votes
0answers
22 views

Bash variable name is result of concatenation [migrated]

I'm trying to do : declare -a array=(first second third) for i in ${array[@]}; do ${i}_arg=$(some commands here...) done Expected result: first_arg=something1 second_arg=something2 ...
1
vote
1answer
34 views

Bash Script to set Linux OS

I'm working on a bash script and ran into an issue. I'm pushing what I know from using normal if/fi statements and trying to use them to set variables related to picking up the OS version, such as RH ...
1
vote
2answers
212 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 ...
5
votes
0answers
98 views

How to check from bash if package exists in debian [migrated]

I would like to make a installation bash script, where I would like to install mysql server. On linux mint I had followed code: apt-get -y --force-yes install mysql-server-5.6 but I installed new ...
14
votes
5answers
9k views

Newline-separated xargs

Is it possible to make xargs use only newline as separator? (in bash on Linux and OS X if that matters) I know -0 can be used, but it's PITA as not every command supports NUL-delimited output.
-2
votes
1answer
34 views

bash: variable increment does not occur

I have a problem in one of my bash shell scripts. Asked a few colleagues, but they all just shake their heads (after some scratching), so I've come here for an answer. According to my understanding ...
0
votes
1answer
44 views

bash script doesn't run properly in crontab but runs fine manually

I wrote a small script to determine the average IOPs per hour in which I later manually convert to a graph and spreadsheet for management to discuss a potential SAN upgrade for an upcoming expansion ...
1
vote
1answer
47 views

Why is PATH wrong with cron entry? [duplicate]

I have an entry in cron.d: 31 17 * * * root /home/some_user/.bash_profile; /home/some_user/bin/some_script The profile sets a specific path, and I echo the current path in the profile to ensure its ...
10
votes
7answers
5k views

Setting the Timezone with an automated script

I'm writing scripts to automate setting up new slicehost installations. In a perfect world, after I started the script, it would just run, with no attention from me. I have succeeded, with one ...
6
votes
7answers
5k views

how to write a script that only acts on new log entries

I feel like this should be a simple thing but I am having a hard time figuring it out. I am trying to write a script that will monitor one of the apache log files and take some specific action. But ...
21
votes
6answers
9k views

Can't log in via SSH to any accounts set to use /bin/bash as a default shell

I'm trying to install bash as the default shell on a ARM Linux running on an embedded device (Synology DS212+ NAS). But there's something really wrong, and I can't figure out what it is. Symptoms: ...
25
votes
8answers
26k views

How to add a timestamp to bash script log?

I have a constantly running script that I output to a log file: script.sh >> /var/log/logfile I'd like to add a timestamp before each line that is appended to the log. Like: Sat Sep 10 ...
5
votes
4answers
10k views

In unix, what's the best way to reduce the size of a massive log file that is actively being written to?

On a linux server, I want to reduce the size of a log file which is several GB big. Cutting off the top half, or maybe the first million lines would work.
2
votes
2answers
2k views

How to install latest version of imagick on centos 5.8 64bit using bash

How can I download and install latest version of imagick on centos 5.8 64bit using bash for php 5.4. >yum info php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * ...
2
votes
3answers
197 views

No shell and launch application on login

I am working on migrating an application from OpenVMS to RedHat Linux 6. The application is a green screen terminal application. The users will log into Linux via SSH and the application should ...
-1
votes
2answers
612 views

Bash script to kill specific process running longer than 5m [closed]

Hi I'm looking for a BASH script for CentOS 6.5 that kills a processes by name that's been running longer than 5 minutes. I asked this question before and received a response that doesn't work under ...
-3
votes
2answers
858 views

Get full physical Ram memory with bash

I know some of you might find my question stupid but i need to know how much ram is installed on a centos box Yes i know it can easily be done by using the command awk '/MemTotal/{print $2}' ...
-1
votes
1answer
27 views

Linux - Print specific line from output [closed]

I am used to working with single line output and can use $1 $4 $8 to specify certain items in that line, but I have never worked with multiple line outputs and would like to just print one line ...
1
vote
2answers
55 views

password check in bash script calling on expect

Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all ...
0
votes
2answers
43 views

Print last column containing spaces and special characters

I need a full path/command thats been execued to start a process thats exposed on the network - listens on tcp/udp . I did manage to get all of that using below "one liner": netstat -nlp46|tail -n +3 ...
0
votes
1answer
64 views

Nagios bash syntax error

I want to refer with this question to the following post where I got the Skript: Post with Script I'm using Bash 4.1.2(1) and when I try to execute the script, I get following error messages: ...
0
votes
1answer
18 views

Export or Forward /var/spool/mail/USER (readable for customer)

there are some bounce mails in the /var/spool/mail/USER directory that failed to send. Now the customer receives all of those mails from us because he does not have direct access to them. I can ...
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 ...
1
vote
0answers
49 views

Is rbash secure if user login and ssh passwords are disabled?

I've got a server that I want to use as an SSH gateway for remote and local port forwarding. I don't want arbitrary commands to be able to be executed on it, only my scripts. I keep reading about how ...
0
votes
0answers
13 views

Remap cursor keys in bash vi mode to <nop> (disable cursors) [migrated]

When using vi mode (set -o vi) with Bash, is it possible to remap the cursor keys to so that they don't work (and be forced to use h, j, k and l movement keys)? Under vim (the editor), I can do it ...
1
vote
0answers
20 views

Recover last argument of the last command in bash' vi mode [migrated]

When using bash's vi mode (set -o vi), is it possible to recover the last argument of the last executed command? This is done in emacs mode with ESC + . , and I would like to do it in vi mode as well. ...
2
votes
4answers
390 views

Use logger in shell script

How can I use logger in a shell script? If I run ntpd -qnp pool.ntp.org 2> >(logger) in console, it works as expected. If I put it into a shell script #!/bin/sh ntpd -qnp pool.ntp.org ...
1
vote
1answer
23 views

ssh remote command execution quoting

I found this solution that works for me, but I don't understand how it does work given that the sed command encloses its own parameter in single quotes, and the whole ssh command is also passed in ...
13
votes
4answers
4k views

Run an interactive bash subshell with initial commands without returning to the (“super”) shell immediately

I want to run a bash subshell, (1) run a few commands, (2) and then remain in that subshell to do as I please. I can do each of these individually: Run command using -c flag: $> bash -c "ls; ...
4
votes
2answers
479 views

Faster way to ping URL than curl [closed]

What would be the fastest way to check whether the specified URL is working? (responding in OK http status code)? For now I'm using curl, but I have bunch of URLs to test in a loop, so I'm looking ...
0
votes
0answers
37 views

BASH: bash completion function in a custom script

How I can add existing function to a custom script? complete -F _known_hosts test.sh - this works on the command line however when I tried to add this to my custom script it's not working as ...
13
votes
13answers
29k views

Stop ssh login from printing motd from the client?

I've got SSH passwordless set up, however it prints the MoTD when it logs in. Is there anyway to stop that happening from the client side? I've tried ssh -q but that doesn't work. I don't want to use ...
14
votes
2answers
295 views

How to uninstall newly installed dependencies for a RPM package?

Is there an easy way to make a list of the dependencies a newly installed RPM package will install with yum? Example: If you do yum install ruby then it will also install some rubygems. But when I ...
0
votes
2answers
25 views

Why my netcat connection doesn't send the file correctly?

I wrote this script to send a file using netcat. My intention is to open the netcat port in the destination server from the origin, this way I do everything with just one script instead of having one ...
20
votes
2answers
6k views

Why does redirecting 'script' to /dev/null/ allow 'screen' to work while su'ed as another user?

I was su'ed into a user to run a particular long running script. I wanted to use screen but I got the error message "Cannot open your terminal '/dev/pts/4' - please check." So I Googled around and ...
0
votes
9answers
405 views

What is the easiest way to find out in what file a word is contained?

I've got a number of .conf files in the following "lxadmin" directory and suspect that the text "tanguay.info" is in one of them somewhere. I do this command: cat /etc/httpd/conf/lxadmin/* | grep ...
0
votes
1answer
28 views

convert for loops to while loops comparing arrays

On occasion (like 4 or 5 times in an 8hr shift) I have to check that the sites from being served from a shared server are loading. I currently have a script that does this, however I am using nested ...
0
votes
4answers
281 views

how to run the dialog command with proccess

Please look on my code – ( bash script ) I want to display both dialogs on the screen on the same time, one dialog display the: tail –f from - /var/log/proccess1.log , and the second dialog ...