Tagged Questions
0
votes
1answer
27 views
pass command with stdout to a bash function
ok.. this is the deal. i have a bash script like the following. the script is only to show you what i mean .. it may look strang... but is exactly what i need.:
#/bin/bash
runcommand () {
...
-1
votes
2answers
24 views
linux script - find java process and restart it if it is more than 80% Mem High
I want to put in crontab a shell script that will monitor the java process and if it's the memory is more than 80% then I want to restart it.
can any one help?
Thanks!!
Elad.
0
votes
6answers
63 views
What does passing the -xe parameters to /bin/bash do
Exactly what the title says. I'm not having much luck finding the proper documentation to see what -xe does in the following use case:
#!/bin/bash -xe
what do those parameters do and where it is ...
1
vote
0answers
37 views
Documentation for bash arguments [closed]
Possible Duplicate:
What does passing the -xe parameters to /bin/bash do
Where is the best place to read documentation on what parameters that are passed to bash such as -x and -e are? I ...
1
vote
2answers
47 views
changing directory in bash script
I have the following script:
cd "/usr/local/bin/"
/sbin/startproc ./program1
I have a license in the /usr/local/bin directory and if the program isn't started from there
it won't launch ...
1
vote
4answers
28 views
Stripping “extra spaces” in du -sk for bash script?
I am trying to use du -sk to get the size of two folders
dirsize_temp=`du -sk /folder/path/here`
and then an if statement to compare the sizes. The only issue is that when you run the command, it ...
0
votes
1answer
52 views
Syntax error near unexpected token `fi'
I have been trying to write a while loop bash script that will check the size of two directories, and echo that out to a text file in the www folder. After my while loop stubbornly refused to work, I ...
0
votes
3answers
58 views
In a shell script, perform different actions depending on the file on a another server (web accessible)
I've been having trouble with firewalls lately on a few different servers. And im wanting to create a script that will run once every hour or so, and check a file on an external server and execute the ...
1
vote
1answer
35 views
Scripting postgres synchronization--is this secure?
I have written a script to synchronize (recreating from scratch) a production database with a development database, and I wanted insight into potential security flaws/issues, the script is posted ...
2
votes
1answer
71 views
Self watchdog script
Has anyone written a self-watchdog script and can share the way it was resolved?
I have DD-WRT on one of the routers and can make only one startup script. The problem is doesn't get run. If I log on ...
2
votes
3answers
142 views
Detecting upload success/failure in a scripted command-line SFTP session?
I am writing a BASH shell script to upload all the files in a directory to a remote server and then delete them. It'll run every few hours via a CRON job.
My complete script is below. The basic ...
3
votes
5answers
131 views
How do I read multiple lines from STDIN into a variable?
I've been googling this question to no avail. I'm automating a build process here at work, and all I'm trying to do is get version numbers and a tiny description of the build which may be multi-line. ...
2
votes
4answers
112 views
bash : “set -e” and check if a user exists make script exit
I am writing a script to install a program with bash, I want to exit on error so I added "set -e" in the beginning of my script.
The problem is that I have to check if a user exists inside of my ...
3
votes
3answers
81 views
simple nagios script failing
What is wrong with the following if-then-else? I never can hit the else.
if [ $result > $value ]; then
echo HEALTH: OK. Result is $result Value is $value
exit 0
else
echo HEALTH: ...
0
votes
2answers
73 views
Use number of downloaded file in wget as variable in bash script
Can I get the number of downloaded files with wget -r and use that as a variable? I want to write a script that runs multiple wget commands in it (using -q so i can control output) and then at the ...
-1
votes
1answer
101 views
shell script to replace subnet mask and default GW
I need to create a shell script the gets as first parameter a subnet mask and as the second paramater a GW address.
something like this: "replace_IPs.sh 255.255.0.0. 10.0.0.254" by running this ...
1
vote
2answers
64 views
Weird errors in a BASH script
I am trying to fix this error I keep seeing, and I'm not sure why I'm seeing them. The script generates a list of files older than 7 days, then tars/gzips them into a backup directory. Finally it ...
0
votes
1answer
70 views
start apache script
I've got Apache installed on my local Linux (sabayon) OS, just for programming testing.
What I want is a script so that the server starts right away when I want it.
This is the code:
#!/bin/bash
# ...
1
vote
3answers
64 views
Why is ``head`` hanging and not terminating?
I have a shell script that has to find the newest file on a remote host. I have this bit:
ssh -q $HOSTNAME -t ls -t -1 /path/to/somewhere/ | head -n 1
It prints the first line, then waits and ...
0
votes
1answer
113 views
llinux - replace subnet mask in ifcfg-eth0 with sed or awk
I have 30 linux servers that I need to change subnetmask. I want to use a simple script or a simple command to change the subnemt mask from 255.255.255.128 to 255.255.255.0 in ifcfg-eth0.
can ...
4
votes
6answers
215 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 ...
0
votes
2answers
78 views
php5-fpm: bash script to check config before restart
I write a script to create new vhost on Nginx. That script creates Ningx vhost config file, vhost user and dirs, php-fpm pool file.
At the end of the script, I would like to check if config is ok ...
0
votes
2answers
150 views
CentOS: E-mail notification of failed ssh login attempts
Under CentOS, I need a script that will run every 10 minutes and e-mail me if there are any new failed ssh login attempts in /var/log/secure.
7
votes
3answers
91 views
How to safeguard a shell script against running out of control?
I've recently had an experience of writing a shell script which crashed a server (and damaged a partition) by consuming all resources. It was hooked up to a cron job, and it seems it took longer to ...
4
votes
3answers
311 views
Parse and convert ini into bash array variables
I'm trying to convert an ini file into bash array variables. The sample ini is as below
[foobar]
session=foo
path=/some/path
[barfoo]
session=bar
path=/some/path
so these become
...
3
votes
1answer
125 views
Test file for specific permissions
I have a script where I'd like to test a file for specific permissions, specifically 0644, if it is not that then chmod it.
I know I could just chmod it and let it fall through in case it already was ...
2
votes
3answers
125 views
Prevent sudo, apt-get, etc. from swallowing pasted input to STDIN?
I often write up wiki instructions to install various server packages on Ubuntu (11.10 Oneiric at the moment). They always involve things like:
sudo apt-get install -y postfix
sudo cp ...
1
vote
2answers
56 views
What's a good way to email sysadmins the first time a failure happens?
I have a cron job which will copy some files and such. From time to time it will start failing due to an inaccessible host. When it starts failing, I'd like to get notified - but I don't want an email ...
0
votes
2answers
70 views
mkdir: cannot create directory `../abc/2011-11-23: No such file or directory
I have got a sftp script that downloads the archives , unzip it and then rename the files according to date and moves it to respective folder.
I had to move the script from USB drive onto a separate ...
1
vote
2answers
100 views
rsync shell script with input
I would like to have a rsync shell script that the user will enter the folder or file to sync to another server.
i.e. - ./deploy /html/ or ./deploy /html/kuky.txt
the script will wait for the input ...
0
votes
2answers
126 views
Need a bash script to replace static IP with a new IP address
I would like to have a bash script for Centos machine.
I want the script to show me the current IP Address /subnet mask / Default GW.
and give me option to enter a new IP Address /subnet Mask / ...
0
votes
1answer
107 views
How to execute the “while” statement after fetchmail do his job?
I have this script inside /etc/ppp/ip-up.d/script
#!/bin/sh
/usr/sbin/postqueue -c /etc/postfix -f
/usr/bin/fetchmail -v -f /etc/fetchmailrc -L /var/log/fetchmail.log
while ! postqueue -p | grep -q ...
0
votes
1answer
95 views
How can I append IPs (a whole class C range) to a file using shell scripting? [closed]
How can I use shell scripting to append a range of IPs to a file?
1
vote
3answers
105 views
How to loop queue checking code? [closed]
Possible Duplicate:
Disconnect modem when postfix queue empty
This script code checks to see if the postfix mail queue empty and if true it disconnects my modem.
#!/bin/sh
postqueue ...
3
votes
2answers
147 views
Repartitioning two disks without a loss of data
I am interning at a software company and I have hit somewhat of a brick wall. Here is the deal:
The Problem: We have some boxes around here that were incorrectly partitioned for 2 x 500 GB drives. ...
1
vote
2answers
36 views
Repartitioning two disks without a loss of data [closed]
Possible Duplicate:
Repartitioning two disks without a loss of data
I am interning at a software company and I have hit somewhat of a brick wall. Here is the deal:
The Problem:
We have ...
0
votes
1answer
51 views
bash script parameters & error trapping
I've created a bash script for a cron job that I'm using to convert an uploaded file to a couple of formats and then moving it to another folder where another cron job will store it away, etc.
The ...
6
votes
4answers
933 views
Is it possible to run a command on windows server from Linux?
I want to restore a sqlserver db backup on remote windows server from linux. I tired "net rpc" but there is nothing for execute a command or script on remote server.
4
votes
5answers
140 views
Bash: Execute piped lines from stdin
I haven't found a solution to this after some searching. I think the search terms are just too general. I'd like to know how to execute a number of lines (at the bash prompt) which are generated by ...
1
vote
1answer
128 views
Telnet exit status are equal for connection refused and connection tiemout
I create a bash script that check the connection to an host with telnet.
That's the core code:
telnet $X 2404 < $TEST &>/dev/null
if [ $? -ne 0 ] ; then
echo -n "$X " >> $LOG_FILE
...
2
votes
4answers
218 views
Lightweight script for monitoring disk space, ports, etc.?
If I want to monitor some machines that I'm not the primary maintainer of (ie, I don't have access to install packages), are there any lightweight alternatives to things like Nagios? I'm looking for a ...
0
votes
1answer
131 views
how to manage dates in shell
emphasized textI have a file containing 14000 dates . I wrote a script to find the last 5 days ,
26/03/2002:11:52:25
27/03/2002:11:52:25
29/03/2002:11:30:41
30/03/2002:11:30:41
26/03/2002:11:30:41
...
5
votes
3answers
196 views
Bash variable assignment using another variable as part
I have the following excerpt from a bash script used to backup a database
#!/bin/bash
DB=database_name
DBUSER=username
FILENAME=$DB_$(date +%s).sql
I am trying to reuse the value of DB within the ...
0
votes
1answer
115 views
Centos LInux shell script execute 2 minutes after the server has been rebooted
I would like to have a simple shell script that will be executed 2 min after my server came up
after reboot.
I just want to have a service restarted.
can anyone advice?
Thanks.
1
vote
2answers
171 views
Why is this bash script not working?
I'm making a bash script which checks the available space on disk:
if [ check_space -gt "85" ]; then
echo "removing"
else
echo "not removing"
fi
check_space returns a number like 52 and the ...
2
votes
5answers
89 views
How to remove a certain symbol for a bash script
I have a bash script where I get the disk usage, for example 60%. How can I remove the % symbol? Using grep or awk?
0
votes
2answers
105 views
Problem with loading .sh files call out by /usr/bin/php
When my web site is calling out a bash script with /usr/bin/php i'm geting this error
Failed loading /projects/common/zend/lib/ZendOptimizer.so: /projects/common/zend/lib/ZendOptimizer.so: cannot ...
2
votes
2answers
60 views
Send bash -x output to logfile without interupting standard output
Is there a way to send the information displayed by running a bash script with the -x option to a file, while not changing the standard output seen by a user running the script?
This is a debugging ...
6
votes
2answers
257 views
Where do you share or find useful powershell, bash, batch, vbs, scripts?
I just wrote a quick little powershell script to make my life easier for a task that I was facing. I thought it would be nice to put it on the Internet, where someone else may also find it useful. The ...
0
votes
2answers
173 views
Script to run vpnc, and enter password
My vpnc connection is breaking quite often, and my friend created a script, which runs vpnc, and runs another "guard" script, which in turn checks every minute if vpnc is still connected, and connects ...