The shell-scripting tag has no wiki summary.
-1
votes
1answer
27 views
Bulk BIND zones creation [closed]
How can I create zones for 50 domains on Ubuntu 12 VPS? I have webmin (which allows me to use BIND to create/ manage zones). I was able to figure out what gets created to add a zone successfully.
But ...
0
votes
1answer
30 views
Solution to start/stop many instances of one application
I have one tool that performs a long-running task. This tool accepts a configuration file. Right now I need to run simultaneously about 15 instances with different configs (using screen for this).
...
0
votes
2answers
43 views
linux + how to identify if file is pointed by link/s
I create new file called - 192.9.200.1
touch 192.9.200.1
then I create new link that will be pointed to 192.9.200.1 file
ln -s 192.9.200.1 file
so finally I get:
ls -ltr /tmp
...
0
votes
3answers
51 views
Connect to cisco switch using shell script
I would like to run a daily script the cleans my switch arp.
I enabled SSH on my switch.
how do I connect to the switch using a simple shell script?
I'm not sure how to provide the SSH password and ...
0
votes
2answers
46 views
linux + delete duplicate IP's from file
what the best way to remove duplicate IP's from file
I use the command:
sort file | uniq
but I am not sure if this is the best way , maybe I missed something?
remark: my file contain two ...
0
votes
1answer
28 views
Hudson kills the process at end of the shell script
Im configuring Hudson to automate deployment process. In shell script I start the server using different user and Im able to see the logs which says server is successfully started and able to access ...
1
vote
2answers
60 views
What is this specific shell script statement validating?
I'm not a good Shell Script expert. Can somebody help me to understand and explain the statement [ ! -z ${TRUE:-} ] && [ ${TRUE:-} == 'true' ] &&from the following snippet. What is ...
-1
votes
1answer
30 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
4
votes
2answers
156 views
supress expansion of * in echo
I am working on a script which dynamically executes some queries on daily basis. These queries are coming from a table in the database.
Here is the sample output of the query table:
...
0
votes
1answer
45 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
3answers
102 views
In zsh, how do you redirect stderr to /dev/null within a for or foreach loop?
I am trying to accomplish something that is easy in bash: look for files in a folder and source them if they exist (and do not output if no files exist).
In bourne shells this is how to do it:
if ...
0
votes
0answers
24 views
Get Rsync status for output
At the end of a successful rsync job, I get the typical:
sent 6022622 bytes received 4751961 bytes 69738.40 bytes/sec
total size is 3328464484 speedup is 308.92
I call my rsync job via a shell ...
0
votes
1answer
68 views
Bash: php comand not found when called from a script run with sudo
I have this weird problem. The php command is not found in one specific sitiation.
I try to call the command in three different ways. Only one of them fails:
Being user john I create a simple ...
-1
votes
1answer
55 views
run expect script from other shell [closed]
my target is to create the /var/tmp/add_user.bash script by /var/tmp/create_script_add_user.bash script
and run the expect script ( add_user.bash ) from create_script_add_user.bash script
the ...
1
vote
2answers
24 views
script reading from new descriptor in read
I have a script that asks some questions to the user and repeats the question until the user has answered something appropiate. This is done with an infinite loop that is break'd when an acceptable ...
0
votes
1answer
47 views
can't access sourced variables inside Upstart script stanzas
I'm trying to use the variables defined in /etc/environment in an upstart script.
I'm able to export the variable to the child process but for some reason I not able to use them in the upstart script ...
0
votes
2answers
89 views
re-create new link and remove the old link on one command
according to ln manual page:
man ln
-f, --force
remove existing destination files
so as I understand if I want to re-create new link to some destination directory/file
I can ...
0
votes
0answers
85 views
How to get range time a log file in shell script
How to get range time using awk command?
I have two variables $from and $to with format (hh:mm:ss)
I want to get the range time between two variables.
For example: get all range time between:
...
0
votes
4answers
91 views
How to automatically clean up date stamped logs
I have an apache web server with various virtual hosts. Each virtual host logs to date stamped files using cronolog. The result is that I end up with a lot of files like this:
----rw-r-- 1 root ...
0
votes
2answers
124 views
FreeBSD rc.d scripts do not return to proper shell
My interesting problem is that when running some rc.d scripts they do not actually drop back to the root shell, but leave me at an intermediate shell as the user they're supposed to be running as.
A ...
1
vote
2answers
180 views
shell script in crontab, not all output being logged
I've got a simple shell script that runs a few LFTP commands and processes the files.
When running straight from bash I get full output of those LFTP commands on screen.
When running from crontab ...
-2
votes
1answer
50 views
case + how to implement equal or less or greater in case syntax
my target is to verify the range of number with (only with - case + esac ) , and print the range
so for example
if number is between 0-80 , case will print
>=0<=80
or if range is ...
0
votes
3answers
42 views
Finding the file/script that invoked a process
I do have a high CPU utilization PhP Process. This process in turn seem to invoke mysql and
both processes together are using all the CPU cores and RAM
using
ps aux | grep php , i could get the ...
1
vote
1answer
120 views
Mysql incremental backup and point in time recovery
I have a requirement for doing Incremental backup of MySQL database. For which I'm writing a shell script using the concept of binary logs.
Now, the scenario is such that a full-backup will happen ...
-1
votes
1answer
32 views
running script containing sudo in cron [duplicate]
#!/bin/bash
value=$(<man.txt)
echo "$value"
if [ "$value" == "true" ]; then
echo "startedif_manthan"
ps -ef|grep sym |awk '{ print $2 }'|sudo xargs kill -9;
sleep 30;
sudo sh ...
-1
votes
3answers
58 views
Cannot start a script
#!/bin/bash
value=$(<man.txt)
echo "$value"
if [ "$value" == "true" ]; then
echo "startedif_manthan"
ps -ef|grep sym |awk '{ print $2 }'|sudo xargs kill -9;
sleep 30;
sudo sh ...
-1
votes
1answer
37 views
Different behavior from ubuntu server and ubuntu client on windows [closed]
#!/bin/bash
# Reading
cat /home/radiare/Desktop/first.txt | while read LINE
do
if [ "$LINE" == "false" ]; then
echo "Inside first loop"
break
fi
done
cat /home/radiare/Desktop/second.txt | while ...
-3
votes
2answers
64 views
perl one liners + add empty line after the last line [closed]
please advice
what need to change in the perl syntax in order to add new empty line after the last line?
example
IP_INFO=12.23.2.1
echo IP= | perl -pe "s/$/$IP_INFO/" 1>>file
.
...
1
vote
4answers
49 views
Howto: command/tool ability check
When developing a shell script that should run on various unix/linux derivates, i sometimes have the problem that some tools have to be called in a different way compared to other systems. For example ...
0
votes
1answer
47 views
ZSH escaping / file matching pattern
This works from command line:
scp -r ^.git b:/home/wopi/blyzics/.
when I paste the above line in a script like this:
#!/usr/bin/env zsh
scp -r ^.git b:/home/wopi/blyzics/.
And run it
...
0
votes
1answer
114 views
ssh tunnel and rdesktop in one line
To access a windows machine remotely I have to tunnel through a ubuntu server of mine. To setup the tunnel I have
ssh -l root -C -L 9999:windowsmachine:23389 myserver
Then I have to open another ...
-1
votes
3answers
146 views
Script to restart httpd if crashed
With heavy trafic, it happen that's my HTTP service crash on my dedicated server. Then, I have to restart httpd service manually.
I just search for a shell script that's detect if HTTP service is OK ...
1
vote
1answer
60 views
escaping spaces in shell script
yesterday="2010-06-23 00:00:00"
today="2010-06-24 00:00:00"
mywhere="lastupdate>'$yesterday' and lastupdate<'$today'"
mysqldump $param ticket --no-create-info --where=\"$mywhere\"
The last ...
-1
votes
3answers
469 views
how to run shell commands from apache (through php )
I'm using redhat 6
I have the following shell commands that I need to run from the webserver (apache -> through php ) that basically move & overwrite a file , kill a process and starts another ...
3
votes
1answer
119 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 $?
...
8
votes
3answers
1k views
How do I sleep for a millisecond in bash or ksh
sleep is very popular command and we can start sleep from 1 second
# wait one second please
sleep 1
but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ...
0
votes
1answer
118 views
Using NFS mount script with grandfather father-son script but only getting 6 daily backups. I should also have 4 weekly and 2 monthly backups
I'm using rsync to clone changes from a remote server(MT DV4.0) to a local one(ubuntu 11.10). I'm then using the following copy/paste script to compress then archive the files.
#!/bin/bash
...
0
votes
2answers
92 views
Issues in Play framework Server when I start using su deploy -c “play start”
I have play framework server and Im doing Automation using Hudson,
When I start the play server using su deploy -c "play start" it's fine the logs are getting updated and server is started.
The same ...
0
votes
1answer
90 views
How to combine outputs of ps and lsof
Usually output of ps has a pid somewhere. Is there a way to combine this, preferably with a one-liner, with an output of lsof ?
e.g.
27915 ? Ss 0:03 gpg-agent --daemon
gpg-agent 27915 ...
-1
votes
2answers
127 views
shell: create Shortcut command (alias or function) for working with IP address as arguments
I am not sure if I performed the following illegal or true
but what I need is - to create set of ready commands
so if I need to use , for example to match IP address with 4 octet
I can use the ...
-2
votes
1answer
99 views
linux + count how many digits in IP address [closed]
I write the following syntax (exist in my ksh script) in order to find how many digits I have in IP address
IP_address=127.1.1.1
echo $IP_address | sed s'/\./ /g' | wc | awk '{print $2}'
4
.
...
-1
votes
1answer
126 views
shell script - while loop, handle the exception
I am running a shell script with a while loop and it exits with the below error, how could I avoid it or catch the error and let the loop to continue ? ie how could I handle the exception
stty: ...
-1
votes
4answers
94 views
Shell script for loop is behaving unexpected [closed]
Shell script for loop is behaving unexpected ! The requirement is need to iterate the loop line by line of the property file. Its mandatory to use the for loop.
hostnamefl=/tmp/propperty.txt
for ...
0
votes
1answer
47 views
Oracle Golden gate version using shell scrip
I am trying to grep the Oracle golden gate from a remote machine, But along with version it is giving some error details also, How do I resolve it ?
user@serverhost:/dbei > echo <golgengate ...
0
votes
3answers
102 views
grep + Regular Expressions to match uniq number
My target is to verify if $FILE is a backup file ( backup file ended with xxxx.xx.xx.xx number
Example of backup files
ls /etc/VRTSvcs/conf/config
main.cf.17Dec2012.09.10.14
...
-1
votes
2answers
183 views
Configure the UPS apcupsd demon to run a script?
I have a ups connected to a Linux server with a usb cable, i installed apcupsd demon and i was wondering how to instruct it to run a shell script i created when a special condition occurs?
i.e. the ...
0
votes
1answer
140 views
linux cron mysqldump: php exec() vs shell script vs direct command in crontab
The system is running CENTOS 5.8, Apache 2.2.3, MySQL 5.0.95, PHP 5.3.3
We run mysqldump daily for a few databases. It's run via a php script called in crontab.
They are run at the same time and ...
0
votes
1answer
75 views
Linux/Solaris verification ( after hostname change ) in files according to hostname rule
According to the following Perl command
( this command part of ksh script )
I can replaced old hostnames with new hostnames in Linux or Solaris
previos_machine_name=linux1a
...
1
vote
5answers
82 views
Solutions for scheduling cronjob
I have setup a list of cron, Some of the cron script takes a long time to run (like 1-5 hours, and they are increasing every day). I do not want to run two cron scripts at the same time, as I do not ...
0
votes
1answer
265 views
linux\solaris + print specific date format from file
subject - print file date on solaris as format: yymmdd ( yy - year , mm - month , dd - day )
on Linux machine I type the following command in order to get: file date
as the following:
ls -l ...
