0
votes
0answers
21 views

Who have logged in the system during the last day and which command(s) s/he has executed? [closed]

I want to write a shell script to know that who have logged in the system during the last day and which command(s) s/he has executed? I need to execute in both Mac OS X and Ubuntu. But its okay to ...
0
votes
0answers
37 views

wget failing when I enter variable name in command [migrated]

I have a small bash script to download a file from my webserver. I pass the $File variable through the command line and then insert it into the wget command as follows: File=${1} wget -a ...
0
votes
2answers
45 views

Capture piped multiline grep output into a variable

I'm using Zabbix's zabbix_sender.sh script to push exception stack traces to my remote Zabbix monitoring server. zabbix_sender.sh requires a key and a value for any data that it sends. It can read ...
-1
votes
0answers
49 views

What are ways to encrypt a password inside an environment variable [migrated]

I have this file I use to set my username and password before exporting the value. #!/bin/bash echo -n "User:"; read user echo -n "Password:"; read -s password export ...
6
votes
1answer
108 views

Providing normal users(non-root) with initialization and shutdown auto-run capabilities

I'm hosting an experimental/testing Linux box, running Debian Wheezy 7.4.0 distribution. Different users log into the machine over ssh to their accounts and are allowed to run the development tools ...
2
votes
4answers
137 views

Starting a script as another user

I've created a script in /etc/init.d/ which has to run several other scripts from other (non-root privileged) users from their home directories, as if they started them. I launch these scripts ...
0
votes
1answer
38 views

Finding a user's home from bash

I'm trying to get the value of a user's home from a puppet script. This particular user is a Samba user, not a local one, with the username of the form DOMAIN\user. I've tried the following, with no ...
1
vote
0answers
38 views

Using 'find' to email me those files modified recently [migrated]

I'm using 'find' at the end of a script to email me any .log files in the current directory that have been modified in the last 6 hours. I need this because the file names change so I can't be any ...
0
votes
2answers
33 views

Creating an environment variable for a specific user

When you set an environment variable in linux is it set only for the user who executes it, or can you specify a user when you store it, or instead is it always available for all users?
1
vote
3answers
58 views

Any Linux tool to create a repo file?

SuSE's package manager zypper is able to create repository file in /etc/zypp/repos.d/. zypper -n rr myrepo zypper -n ar -f http://path/to/myrepo myrepo I'm looking for an equivalent tool do the ...
2
votes
1answer
124 views

Bash: two commands in dollar-parenthesis don't have same behavior

I don't undertsand why, in Bash: echo $(hostname --fqdn) works, echo $(id -un) doesn't (id: –un: No such user). Backticks give the same results. Is there some good practice for using this ...
0
votes
1answer
29 views

Riverbed Stringray TrafficManger - API calls for Autoscaling

I am looking for advice on writing a bash script to put new server that we spin-up in AWS and get them added to our Stingrays. We are creating a new environment in AWS that will be muilt-AZ in AWS ...
0
votes
1answer
48 views

Can a user be excluded from /etc/profile.d scripts?

I am having a problem using Rsync/SSH with a specific user for Amanda backups on a server. rsync -e 'ssh -i /var/lib/amanda/.ssh/id_rsa_amdump' -az otherserver:/dir/to/copy /copy/dir I have noticed ...
0
votes
1answer
39 views

How to find full process arguments and associated listening ports?

I can execute netstat -atulpn | grep java to find all Java processes with their accompanying ports, which is great, however I would like to also have the processes full execution arguments also shown. ...
0
votes
2answers
55 views

Script for search string inside the file for every one hour

I need to write a script where the particular string(alphanumeric) should be searched inside the file with every hour for whole day. And the search should not contain the previous hour results. Time ...
2
votes
2answers
61 views

How to parallelize the for loop while scp the files?

I am running my below shell script from machineA which is copying the files machineB and machineC into machineA. If the files are not there in machineB, then it should be there in machineC. The below ...
2
votes
4answers
67 views

How to migrate ssh key to new CentOS server?

We have lots of scripts that run over ssh through saved (passwordless) key pairs. Both clients and servers are CentOS 6.x.I know that if you get a new client computer (where the scripts are run from), ...
3
votes
2answers
449 views

How to keep: daily backups for a week, weekly for a month, monthly for a year, and yearly after that

I need to backup data and config files on this server, daily. I need to keep: daily backups for a week weekly backups for a month monthly backups for a year yearly backups after that All of this ...
0
votes
1answer
78 views

How to create ssl certificate for multiple domains which requires the CA root key in Linux

I have mail server. There are may domains hosted on it. I am deploying ssl certificate on it. I want that when user access there mail account using https browser should show that certificate is ...
-1
votes
3answers
38 views

How to create batch of specific number of lines in linux [closed]

I have a 10000 lines file.I want to create batches of 100 lines at a time in each different file.I know that this can be done using a while loop.But, I want to know whether it can be directly done ...
1
vote
3answers
63 views

Completely reset PostgreSQL to default?

Question Is there a way to completely reset a PostgreSQL installation on Linux, so it is in the same state as when I installed it? Idea I have considered rm -rf /var/lib/pgsql/* rm -rf ...
1
vote
2answers
92 views

permission denied in running script

I am running a script but there is an unusual warning: This is what happened in my console #whoami root #ls -l test.sh -rwxr-xr-x. 1 root root 1894 Feb 2 01:58 test.sh* #./test.sh -bash: ./test.sh: ...
1
vote
2answers
141 views

Linux Bash IF conditions not processing when running as crontab

So I've made myself a little script which monitors my served directories for any PHP files which have changed. It's designed to run every 5 mins from crontab and email me any changes so that I can ...
0
votes
0answers
18 views

Use tmux for managing multiple downloaders as a supervisorctl service?

I have many data-servers I need to download data from via http as soon as it is available. For each server I start a bash "while true"-loop and within that a wget to poll the server for new data. To ...
-1
votes
2answers
134 views

zcat/gzcat works in linux, not on osx. general linux/osx compatibility

First the specific problem: In linux, I use zcat to list a .zip file. In osx, zcat seems to automatically append .Z to the file name. Various people suggest replacing zcat with gzcat; however, gzcat ...
0
votes
2answers
172 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 ...
0
votes
1answer
117 views

“Long service output” in Nagios gets chomped for some reason

According to this page the limit of $LONGSERVICEOUTPUT$ is 4kB, but in my case, it stops showing the rest of the output after 970 bytes of output (26 lines), where there multiple newlines no long ...
4
votes
2answers
279 views

How to handle IP's with manual failover?

I have two identical storage hosts where the master is the only one the users can access. If the master fails, then I want to manually change the DHCP address, so instead of master points to ...
2
votes
1answer
36 views

Command which will tell me the last time a directory or any of its sub directories have been modified? [closed]

We are trying to deprecate our old Linux home folder server. We still have a few people that are actively using it though. Our plan is to change home folders that no one has used in the last six ...
1
vote
1answer
123 views

Centos syslog isn't logging to custom file from bash script

I'm trying to get a bash script to log to a custom log file using syslog on Centos release 6.5, but it always just logs to /var/log/messages like so: Jan 12 09:54:47 localhost nbsp: Test message ...
2
votes
4answers
145 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
3answers
117 views

How to parallelize the scp command?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
0
votes
2answers
120 views

Gnu parallel & pipe

I want to send each line of a file to another program's stdin, e.g. input.txt line1 line2 line3 I want to use the gnu parallel like this (i.e. pipe each line as stdin to the more command) cat ...
1
vote
2answers
64 views

How do I iterate bash arrays and make an SCP command efficiently?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
1
vote
2answers
52 views

Redirect to stdin instead of argument when using xargs [closed]

for exmaple, using the command cat foo.txt | xargs -I{} -n 1 -P 1 sh -c "echo {} | echo" The foo.txt contains two lines foo bar The above command print nothing.
0
votes
5answers
129 views

Bash script to check if a public HTTPS site is up [closed]

I'm trying to setup another block of code to a bash script to check if a public website on HTTPS is up or not. Can we do this using CURL? Any suggestions what can be used besides CURL. Thanks
-1
votes
2answers
55 views

Compare installed rpm packages with available?

I would like to find the vmware packages that I haven't installed from their repo. The problem is that the output of yum search vmware is not the same format at from rpm -qa|grep vmware. Question ...
0
votes
1answer
126 views

Insserv rejected the script header

I was trying to make an init script for my debian install for supervisor. insserv: Service \$remote_fs has to be enabled to start service supervisor insserv: Service ...
1
vote
1answer
30 views

cp/rsync command with destination as symlink to a directory

I am working on a cPanel backup solution at the moment. We are now informed about this exploit. Exploit : Full ROOT ACCESS to server 1.) create malicious file from, normal user account: mkdir root ...
2
votes
2answers
96 views

executing .bash_profile alias via SSH

I would like to remotely execute a .bash_profile alias, but I cannot find the proper command. I tried: ssh user@host "bash -ic myalias" but it doesn't work I get: bash: cannot set terminal process ...
0
votes
2answers
58 views

This script won't execute on startup, ideas?

The distribution is RHEL 5. The script has been added to chkconfig like so: # chkconfig --add script # chkconfig script on But it refuses to start when taking up the machine, what could be the ...
0
votes
1answer
45 views

Netcat: connection lost before transfer is complete

Interesting thing with Netcat (nc) in CentOS 5 or 6 (nc-1.84-10.fc6 or nc-1.84-22.el6.x86_64). How can I work it around? I can't find a bug about this, but It models a file transfer to a remote ...
3
votes
1answer
132 views

How to detect if mount point exists from init.d script?

After a reboot, I'm executing an application from a mounted network share (autofs) using an init.d script. The script starts by waiting 30 seconds before attempting to execute the command, in order to ...
0
votes
2answers
51 views

Bash -x to file and email

I have a script that issues a lot of commands. I wish to save the output of this script (Errors and stdout) to a file, but I also want the actual commands that were executed to be saved to the file as ...
0
votes
2answers
42 views

Change/Deactivate the shell for an amount of users on SUSE Enterprise Server

I have a SUSE Server to which ~300 users are connecting. About 100 of them have to be deactivated. I think it would be nice to change their shell to /bin/false either with chsh or with usermod. ...
1
vote
0answers
74 views

grep is inconsistently defaulting to grep -P?

I have a script that does some housekeeping that works perfectly well when invoked from an interactive shell, but did nothing when invoked by cron. To troubleshoot this I started a shell with a ...
0
votes
1answer
77 views

How can I measure the cumulative network usage of a process, from execution beginning to end

I want to measure how much bandwidth git pull uses, preferably by prefixing git command with desired program, i.e. nettally git pull Alternatively, is there some sneaky way to accumulate nethogs / ...
1
vote
3answers
58 views

Override path to binary for particular user

My question seems to be trivial but I didn't manage to find anything helpful in internet. I have a binary in /urs/bin/binary but it is outdated and newer version is available on some mount for ...
2
votes
1answer
71 views

possible /how to obtain the return code for a command executed before the last command?

Linux bash (or other shell.) Have you ever fat fingered "echo $?" into something like "echo $4" thereby permanently preventing you from knowing the return code for the previous command? I do this ...
-1
votes
2answers
99 views

how I can get the value of JAVA_HOME from my client

I have nagios client and server, how I can get the value of JAVA_HOME from my client? I have use to set shell command in script that is running from remote host: echo $JAVA_HOME and printenv | grep ...