02-24-2016
Check space and run command
Hey
i have problem with cut and print column
problem is i want to execute shell script to run df -h /tmp
if the result ( Use% ) was more than 50% , run rm -rf /tmp/*
any idea how cut the result of df -h /tmp ?
10 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
Dear Buddies,
Plz Help me out ,,,,,, the Unix Servers i m working on ,,,Somes times run out of space in root ,,,due the generation of a file named STA ....which causes the system to crash ,,,,,
plz hlp me !!!!!!!!!!!!!!!!!!!!!!
how to find out the file ....generation causes ......
... (6 Replies)
Discussion started by: scorpiyanz
6 Replies
2. Shell Programming and Scripting
The have written the below script :-
============================
SPACE=`bdf /DATA_TRANSFER|awk '{print $4}' |grep "%"`
TEST="96%"
if
then
echo "Continue ....."
sleep 2
else
echo " Current space for DATA_TRANSFER is less than 02 %"
echo " Pls clear space and than continue ....."... (2 Replies)
Discussion started by: kamlesh_p
2 Replies
3. Shell Programming and Scripting
If I run the following command remotely after ssh than it works fine
su - oracle -c "/oracle/product/102/db/bin/dbshut"
But If I run the following command it doesn't work
su - oracle -c "/oracle/product/102/db/bin/lsnrctl stop"
Because I think there is a space is present between lsnrctl and... (1 Reply)
Discussion started by: madhusmita
1 Replies
4. AIX
hi gurus,
i have a question:
when run which javac under a user account I got the following results:
PROD DB Server: /usr/java14/bin/javac
DR DB Server: /usr/java14/bin/javac
DEV DB Server: /usr/java5_64/bin/javac
The .profile in all environments are same.
so how do know who is the... (1 Reply)
Discussion started by: lweegp
1 Replies
5. Solaris
Hi,
I have a question regarding finding free space on the disk of a solaris machine.
Many mount points are available in my machine. Right now i am using
df -b option to get the free disk space available.
I have an assignment to check free space on the disk.
I pass the directory as a... (6 Replies)
Discussion started by: raghu.amilineni
6 Replies
6. Shell Programming and Scripting
Hi,
I want to check if the given line from a text file has a spaces in between. if it does, then I want to add '"' double quotes at the beginning and end of the line. Otherwise leave the line as it is.
For example, below is the sample content from my file.
$cat file.txt
test1
test2... (6 Replies)
Discussion started by: svajhala
6 Replies
7. Shell Programming and Scripting
Hi all,
I have a script that can be run via cron or via the command line.
Is there any way that I can place something on the script to be able to distinguish/differentiate whether the script was run via a user in the command line or whether it was run from the cron? (3 Replies)
Discussion started by: newbie_01
3 Replies
8. Shell Programming and Scripting
( sleep 3
echo ${LOGIN}
sleep 2
echo ${PSWD}
sleep 2
while read line
do
echo "$line"
PID=$?
sleep 2
kill -9 $PID
done < temp
sleep 5
echo "exit" ) | telnet ${HOST}
while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies
9. Linux
Good evening, I've got a question, in our production system there is an application called Intermediate which ftp service is the core to to send back and forth from/to diferent destinations
Gradually FS / was ruuning out space and we took a long time to figure out what precesses were eating up... (9 Replies)
Discussion started by: alexcol
9 Replies
10. UNIX for Beginners Questions & Answers
Dear Team,
i need to know in linux if someone run the command in linux server
where i can check on server . i need to know the below points
who (user)
when (date and time)
what (command)
regards,
scriptors (1 Reply)
Discussion started by: scriptor
1 Replies
LEARN ABOUT CENTOS
shell-quote
SHELL-QUOTE(1) User Contributed Perl Documentation SHELL-QUOTE(1)
NAME
shell-quote - quote arguments for safe use, unmodified in a shell command
SYNOPSIS
shell-quote [switch]... arg...
DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
EXAMPLES
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
debug() {
[ -z "$debug" ] || shell-quote "debug:" "$@"
}
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
user_switches=
while [ $# != 0 ]
do
case x$1 in
x--pass-through)
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
shift;;
# process other switches
esac
shift
done
# later
eval "shell-quote some-command $user_switches my args"
OPTIONS
--debug
Turn debugging on.
--help
Show the usage message and die.
--version
Show the version number and exit.
AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
AUTHOR
Roderick Schertler <roderick@argon.org>
perl v5.16.3 2010-06-11 SHELL-QUOTE(1)