0
votes
0answers
27 views

Howto run interactive commands, as another user [migrated]

I'm trying to write a bash script that context switches to another user (root, in this case) executes a set of commands to i. create a user (interactively prompting invoker for username) then ii. ...
0
votes
0answers
60 views

OpenVPN - pushing script to client upon connect

Is it possible to have an OpenVPN server push scripts out to clients upon tunnel establishment? I need to set up specific iptables rules on my Linux clients and would like to be able to deploy the ...
1
vote
1answer
54 views

Email administrator when a duplicate IP is found on the network

It was suggested that I ask this question on serverfault. I know this is a bit of a custom requirement but I was hoping someone currently has (or can put together) a script that checks for duplicate ...
1
vote
0answers
59 views

Linux Script to login to Raspberry pi and run some scripts inside raspberry pi [closed]

This is my scenario, We have some sensors on different sites, these sensors are connected with some equipment having SIM cards in it to allow the internet connection. On the other hand, we have a ...
1
vote
0answers
35 views

Using Windows as middle for migrating between two Linux machines

We're developing a tool that will do a migration between some platforms. Both source and/or destination servers can be Windows or Linux. The tool is currently built in .NET and we'd like to keep it ...
0
votes
3answers
105 views

Exclude with the find command [duplicate]

I need some help getting the find command to work right in a script working on. I need to be able to exclude some directories. Below I have what I'm doing as a work around. sudo find / ( -name ...
1
vote
2answers
160 views

How to set ip address permanently

This might sound a little strange, but I try to achieve to set up an ip address permanently in Ubuntu using the command line, but not an editor. My idea is to provision servers and just type in the ...
0
votes
2answers
46 views

Complex retention policy

I have daily database backups scp'd to a directory on a local linux machine for multiple databases. The naming format is [dbname].backup; there is no timestamp and currently the latest backup ...
1
vote
1answer
43 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 ...
1
vote
1answer
115 views

How to supply custom init script to Azure instance

Is it possible to create an instance specific init script and pass it to a virtual machine that is created via the API of Microsoft Azure? I know this from AWS, but could not find a way to do this on ...
0
votes
1answer
65 views

postfix smtp relay script

I have a Postfix server and using it with Outlook (POP/SMTP). I have different sender addresses for an account. Now I want to configure a relay for a specific sender address. For example I have ...
1
vote
3answers
94 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 ...
-1
votes
3answers
539 views

Script to log internet connectivity outage [closed]

What is the best approach to setting up a script to monitor and report a server's connection to the Internet? I'm not referring to connection to the local network, but rather a server's (or the whole ...
0
votes
1answer
362 views

Tracking down dovecot IMAP user bandwidth usage

One of my customers is using massive amounts of bandwidth, it appears to be related to IMAP and not their actual website. There is a logfile /var/log/maillog which logs each IMAP connection and the ...
-1
votes
2answers
108 views

Monitor port status in Linux [closed]

I want to monitor the list of used ports in linux system. I want to make a script that can run an alert when a new port is up or down. For example when the port 8080 is up , i get an alert: this port ...
1
vote
2answers
131 views

find: how to not have errors (stderr) when no files exists

I have a custom script which gzip log files when they are one day old. In my script all errors (stderr) are logged to a file and at the end of the script I use this file to know if its execution was ...
27
votes
5answers
2k views

How can a Linux Administrator improve their shell scripting and automation skills?

In my organization, I work with a group of NOC staff, budding junior engineers and a handful of senior engineers; all with a focus on Linux. One interesting step in the way the company grows talent is ...
2
votes
2answers
252 views

Add time stamp to script log entries

Currently I have my bash script using exec 22>&2 21>&1 1>$log 2>&1 to write stderr and stdout to a log file. I would like to add a time stamp for each entry, but I haven't ...
-1
votes
1answer
159 views

sed regexp for replacing xxx in define('DB_PASSWORD', 'xxxx');?

I'm looking for a regexp to quickly replace the password inside the following wp-config file, like so: define('DB_PASSWORD', 'xxxx'); Now the config file has many defines, so it essential to only ...
0
votes
0answers
100 views

Suggestions for passing script status back to master controller service

I want to automate our update and upgrade process. What I would like to achieve is a controlling server executes a script of some description on the remote server, it knows the status of the remote ...
0
votes
2answers
90 views

monit displays false number from my uptime script

I've wrote a script for fetch real uptime and display in monit. But I think it displays just exit error status. My uptime script is: #!/bin/sh uptime=`uptime | awk -F " " '{print $3}'` echo $uptime ...
1
vote
1answer
244 views

Is there a programmatic way to determine free disk space on a Linux server?

I have a collection of Linux servers, each of which has a local hard drive with a /tmp directory. Occasionally, the /tmp directory on a server will fill up and cause errors. I want to automate the ...
1
vote
1answer
68 views

suggestions on scripting a move of lots of files from one linux host to another [closed]

I've got several TB and many thousands of files I need to move across the network from one Linux host to another. I'd like to get suggestions on how to script this with the following points in mind: ...
-3
votes
1answer
63 views

On linux, how can I create script to reboot server if it loses internet for x hours? [closed]

I have ubuntu server that has some services that only come back after loosing internet for an extended period of time with a reboot. Does anyone have a script that can reboot server if lose internet ...
1
vote
2answers
289 views

How to prevent termination of long-running Python script

I have a cron job running a Python script on a VM-based remote Ubuntu server. The script takes a couple hours to run, and I'm noticing the kernel appears to be terminating the script before it ...
0
votes
1answer
75 views

Changing Zone files with sed

I have this dns zone file I was unable to change the resource record type A to CNAME @ IN SOA ns1.domain.com. webdev.domain.com. ( 2006080101 ; serial 8H ; refresh 2H ...
3
votes
2answers
90 views

Discrepancy in ssh-agent behavior

It seems like i'm having a bit of a discrepancy between the behavior of ssh-agent for two accounts I have configured. I wrote a simple monitoring script to check on the availability of some VMs we ...
0
votes
1answer
90 views

Close a SSH Session when it suspend

I start a ssh session on a remote host and execute a script on the remote host. The Script is an update script that change the remote IP. Now my local bash script hanging on the line with this ...
1
vote
1answer
367 views

How to not run /etc/profile.d/custom.sh during Secure FTP login

When I attempt to Secure FTP (using WinSCP) to my CentOS 6.4 box I'm prompted with a message that states: Received too large (168438314 B) SFTP packet. Max supported packet size is 1024000 B. This ...
0
votes
1answer
170 views

> /dev/tty - What is the purpose of this command?

This is in one of the rc scripts in Red Hat and I want to understand the purpose of > /dev/tty[n] last=0 for i in `LC_ALL=C grep '^[0-9].*respawn:/sbin/mingetty' /etc/inittab | sed 's/^.* ...
1
vote
2answers
2k views

Is it possible to change BIOS settings from Linux?

I'm trying to write a script to enable IPMI on a ton of machines without having to hook up a KVM to them one by one. Is it possible to change the BIOS settings from Linux? OS is SL6. I understand ...
0
votes
2answers
66 views

get informations from x servers per ssh by bash script

I've server Master,SlaveA,SlaveB,SlaveC, and want to get eg. the space information from the server by executing one bash script on the master. How can I do that? --case-- 192.168.1.1 - Master ...
1
vote
1answer
67 views

Bash, what does this redirect command do

I have a script that looks something like this: ruby foo.rb > log.out 2> error.log < /dev/null & In this case, i understand that STDOUT is redirecting to log.out and that 2> is ...
0
votes
1answer
44 views

#! won't make linux run an interpreter

Here's the script: #!/usr/bin/env ruby CODES = {} puts "ok" Under root user everything is fine: # ./test.rb ok When munin's default interpreter is /bin/false nothing is happpening: # su munin ...
0
votes
1answer
57 views

How to tell passwd to use salted passwords?

I am hunting the web on how to change passwords of an existing user using a salted hash. I found that way with adding a non-existing user: ...
4
votes
4answers
209 views

Disabling ssh as root on Linux boxes and the challenges of writing scripts

It's a common suggestion from security-minded people to disable ssh as root on Linux boxes. My question is this: Let's say you normally write lots of scripts which ssh to a large number of Linux ...
0
votes
2answers
954 views

Linux command to find and delete certain files, but output the result or verbose mode?

So I use these command on my storage server to clean up some junk, but it doesn't produce any output or result. I found the syntax online somewhere and just modified for which files I need it. What ...
0
votes
1answer
88 views

One-liner to retrieve external IP address [duplicate]

Possible Duplicate: Finding the Public IP address in a shell script For use in scripting, it would be handy to be able to do this: IP=`....something ....` echo ...$IP... >> ...
-3
votes
3answers
2k views

How to find files of certain extension and tar each of them in to another location

I have script for finding files of certain type and compress them to a single tar archive and put in to other place. But now, there is a change in requirement, that I need to find files of certain ...
0
votes
1answer
113 views

How to differentiate between start/stop/status in upstart

upstart has post-start, post-stop, etc... and script. as i understood, the script part gets executed on initctl start X or initctl stop X or initctl status X. so how do i know in script which one ...
0
votes
2answers
252 views

Ubuntu unattended upgrades to run at a certain time

I'm trying to work out the best way to run unattended upgrades every Thursday at 3am but can only see a way to run this weekly but not a given time. I thought of one way would be to have a script ...
2
votes
2answers
348 views

Running a script containing find with a regexp fails in cron but works in a shell

I have the following script in my /etc/cron.d: 19 15 * * * root /opt/scripts/clean-nexus-release-repo.sh The clean-nexus-release-repo.sh script looks like this: #!/bin/bash find ...
0
votes
1answer
147 views

Crontab start a screen

I started a screen by shell script in crontab, when I entered the screen, the left side became "sh-4.1#". While I runed the script directly, it was nomal with "[root@localhost data]". What happened? ...
1
vote
2answers
77 views

Download with the bash or Python while keeping the directory tree/structure

I have a list of files that I need to download such as www.domain.com/files/archive.zip www.domain.com/img/icon.ico www.domain.com/files/backup/archive.zip www.domain.com/backup/img/icon.ico ...
0
votes
1answer
163 views

is it possible to provide variable arguments to xinetd service?

I have created a bash script to listen on specific port (using xinetd), so whenever there is someone connecting to port, then it invokes the script and provides its output to user. But i need to ...
1
vote
1answer
135 views

Why would a process monitoring script use exit 1; on finding no problems?

General question: On a Linux (Centos) server, if a process monitoring script run by cron is set to close with exit 1; rather than exit 0; on finding that everything is okay and that no action is ...
0
votes
3answers
674 views

Remove a sentence which starts with word “mark” and ends with “;”

I am having 100's of files that contain sentence that starts with mark and ends with semicolon(;). eg: mark is driving a car; i need to remove every sentence starts with mark and end with ";" How ...
0
votes
1answer
30 views

Get directory of a symlinked script

I have to determine the directory of a script which is symlinked. /usr/local/src/myscript/myscript.sh /usr/local/bin/myscript.sh (Symlink to the one above) A cronjob executes ...
2
votes
3answers
1k views

How can I easily convert HTML special entities from a standard input stream in Linux?

CentOS Is there an easy way to convert HTML special entities from a data stream? I'm passing data to a bash script and sometimes that data includes special entities. For example: "test" ...
5
votes
4answers
418 views

Is there a chroot build script somewhere?

I am about to develop a little script to gather information for a chroot-jail. In my case this looks (at the first glance) pretty simple: The application has a clean rpm-install and did install ...