1
vote
0answers
27 views

Capture transcript of program with redirected input and output [migrated]

A typical interaction for a program I've written might look like this: Enter command: a_command Completed a command Enter command: another_command Completed another command I typically run my ...
-1
votes
1answer
20 views

how to set linux hostname based on flashdisk volume label [on hold]

i'am running live linux, which run from FAT32 flashdisk since i run a lot of pc using this flashdisk, its difficult to identify which IP for its hostname, since its ip need to be dynamically ...
0
votes
0answers
15 views

Script to apply Simple Finder restrictions to Mac OS X user?

Is it possible to script (e.g. with AppleScript or bash shell script) applying the Simple Finder and an associated application whitelist to a local user account on Mac OS X? We are using Mac OS X ...
0
votes
1answer
28 views

Curl pressing enter or ctr+c in order to have the right response [closed]

This is a script that checks my current ip on this site: http://myip.dnsdynamic.org/ and pick the response and calls an API in order to update my dynamic ip. Here the script: curl --user ...
0
votes
1answer
33 views

Bash: delete old files except one

I am using the following command to delete old backup files: find backups/ -name "bak_*.tbz" -mmin +4800 -exec rm -vf {} \; The problem: When there are no new files, than all files are deleted. I ...
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 ...
0
votes
1answer
138 views

Is it possible to auto update php.ini via a bash script? [closed]

I'm trying to write an install script and i need to change the sendmail line in php.ini but I want to do this automatically at the moment I'm doing this manually: sudo nano ...
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 ...
-1
votes
2answers
99 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 ...
2
votes
2answers
197 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
vote
2answers
261 views

Shell script command output in if condition comparison fails to compare to same value string

I'm incorporating a script snippet which determines Android version via: adb shell getprop ro.build.version.release which returns: 4.1.2 or 4.0.4 The snippet currently looks like this: if [ "$(adb ...
2
votes
5answers
202 views

debian bash/sh string execution

I am stuck with this piece of code here user@server:~$ TEST="ssh rsync@otherserver.example.org 'date; hostname -A; uname -a'" user@server:~$ $TEST bash: date; hostname -A; uname -a: Command not ...
0
votes
1answer
51 views

Script to move Maildir contents to its parent dir but for multiple folders

I totally suck at Bash/Python/Ruby/Perl Scripting (need to practice/learn some more) so I'm asking for a little help :-) I need to move about the contents of about 60 Maildirs to their parent folder ...
0
votes
4answers
308 views

Script runs on 50 servers. How can I ensure only one executes a particular step?

I have some work that needs to be done on 50+ servers. The first step is to checkout an updated version of some source code onto a shared directory (assume all have the shared drive mounted). The ...
0
votes
1answer
81 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
312 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
2answers
172 views

Putting this command into bash script

with help of google , script that measures multicast streams bandwidth. Here it is tcpdump -tnn -i eth1 -f multicast | sort | uniq -c | awk '{print $3,"> "$5,$1*$NF/2*8/1024 " Kbps"}' | awk '$1 ...
0
votes
1answer
59 views

How to write a script to install multiple things by just executing it

I have a server (centOS) on which I would like to install the staple development tools. Java, Tomcat, and MySql. What is a good way to write a script that can be ran on newly spawned server so that ...
0
votes
1answer
153 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
votes
1answer
79 views

Can not seem to get expr substr to work

Can anyone tell me what I am doing wrong ? [ /jlr/sub/libexec/vmr-staging ] $ expr substr "onetwothree" 1 4 expr: syntax error I got the syntax from http://stackoverflow.com/a/220464/1150847
0
votes
1answer
101 views

Recursively delete empty folders with verbose output

This should be fairly simple, but I am not sure what i'm missing. I'd like to recursively delete empty directories, and get an output for what's being deleted, this command works for sure, but I just ...
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
59 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
66 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 ...
2
votes
3answers
375 views

Bash script: Monitor hotfolder and partial files

I have a customer that upload files through FTP, I made a script that basically monitor the ftp folder and move the file on a production machine. How can I check if the file has been completely ...
0
votes
2answers
662 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 ...
1
vote
2answers
227 views

change user within bash script

I have a simple bash script which runs great as a regular user. When launched from postfix, it runs as nobody:nobody which prevents many commands from working. Is it possible for the script to ...
0
votes
2answers
609 views

Good pratice to create script to start/stop/restart service?

I was wondering what is a good pratice to create a good script to start/stop/restart some service. I will try to make myself more clear, ok ? Nowadays, I do something like this: let's say I would like ...
0
votes
1answer
30 views

Omnibus uniform Chef version install across platforms

So I'm looking for a uniform way to install chef on a number of different servers running different platforms. I know I can use the omnibus installer for this, but I also need a way to lock or ...
-3
votes
3answers
1k 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 ...
3
votes
1answer
143 views

echo $? doesn't work when executed remotely

When I execute a command as below it gives me an output as expected but when I run the same command on remote server it always gives me echo $? as 0. locally # <some command> # echo $? ...
0
votes
1answer
139 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
74 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
118 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 ...
-3
votes
1answer
297 views

Which scripting language to use to asynchronously ssh into equipment, run several commands, parse the output, and save to a file on my computer? [closed]

There are several points I'd like to stress in my question. I'd like to login by asynchronously ssh'ing into our infrastructure equipment. Meaning, I do not want to connect to only one device, do ...
1
vote
1answer
123 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
1answer
29 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 ...
0
votes
3answers
402 views

When to use Bash, when Python/Perl/Ruby? [closed]

What's your rationale for when to write a Bash script and when to use a more powerful scripting language (Python, Perl, Ruby, ...)? I'm finding that very simple scripts are nicer with Bash, but many ...
0
votes
2answers
127 views

Call 'script' command and exit it from within a bash script

I'm using the linux 'script' command http://www.linuxcommand.org/man_pages/script1.html to log all input and output in an interactive bash script. At the moment I have to call the script command, ...
0
votes
1answer
64 views

run script for all users

I put some script on my ubuntu linux in /etc/profile.d/myscript.sh but it's just work on my user. But it's work only user logged in not when I use sudo. # myscript.sh export MYVAL="HELLO" echo ...
1
vote
1answer
87 views

Script expression to get part of a string?

I'm using the bash shell in CentOS, version ... $ uname -a Linux mydomain.com 3.2.29-48.63.amzn1.x86_64 #1 SMP Sat Sep 15 01:43:12 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux In my shell script, I want ...
2
votes
3answers
957 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" ...
-2
votes
3answers
147 views

Determine hostname of connected ethernet switch

I've a bonding on two interfaces. I want to check the switch-redundancy by getting the hostname (or IP) of the switch, which a given interface is connected. Currently I'm checking this with following ...
3
votes
2answers
336 views

How can I check for a string match AND an empty file in the same if/then bash script statement?

I'm writing a simple bash script to do the following: 1) Check two files (foo1 and foo2). 2) If foo1 is different from foo2 and foo1 NOT blank, send an email. 3) If foo1 is the same as foo2... ...
0
votes
1answer
158 views

Bash and double quotes escaping

If I run some thing like this in shell: curl -I http://example.com -H "If-None-Match: \"da8e7e-557a9-4cbc6f2e68780\"" I get correct result, but when I'm trying ro tun it in my bash script: ...
0
votes
1answer
151 views

How to make a Bash Script take user input for Changing a Password

The following command on OSX will change an Open Directory (Apple's LDAP) password. The $ is the prompt: $ dscl -u diradmin -P 'password' /LDAPv3/127.0.0.1 passwd /Users/username newpassword I ...
0
votes
1answer
182 views

Why does this script stop/fail to continue in Ubuntu 10.04

I have the following script, which works fine until the end of the script where the line to install JRuby 1.7.0.RC2 works, but then the script stops. I added $? at the end of the script to try to get ...
-3
votes
1answer
84 views

MS Exchange script to summarize emails by title

We have Microsoft Server 2008 64 bit running Exchange 2007 64 bit. We would like to run a script to summarize all emails sent to 3 different email accounts on this exchange server according to a ...
3
votes
2answers
605 views

Backup script to FTP with timed subfolders

I want to make a backup script, that makes a .tar.gz of a folder I define, say fx /root/tekkit/world This .tar.gz file should then be uploaded to a FTP server, named by the time it was uploaded, ...
1
vote
3answers
1k views

Bash script for mysql backup - error handling

I'm trying to backup a bunch of MyISAM tables in a way that would allow me to rsync/rdiff the backup directory to a remote location. I've came up with a script that dumps only the recently changed ...