Would like to know how to use the IF...THEN...ELSE statements in C shell
Hi
I've only been using Unix for a few weeks but am really impressed with its capabilities and ease of use.
I am, however, struggling with a shell script at the moment.
I would like automated reports on Disk Usage and available free space. I've written a straight forward script that will do this for me and I'll be dealing with the crontab later to automate it.
I currently use about 20 different servers and the reports are written to a central location. The properties of these servers vary slightly so that the disk name isn't always the same.
I've tried using multiple greps but it doesn't work as I'd planned. Therefore, I'd like to you an IF THEN ELSE statement.
Here is the current code:
I would like to have various versions of the 'Available Disk Space' part so I can be 'server specific'. I'd like to have the script determine the server name (uname -n) and if that equals a certain value (eg SERVER1) then goto the disk space code specific to SERVER1, else, proceed to next command.
I'm not sure how I carry this out - if anyone can help I'd really appreciate it.
Hi I am trying the following in my bash script which logs into my machine and runs a command. Trying to solve this using expect.
The first expect statement is hit and it enters the address "10.10.0.10" but when the second expect statement is hit it exits
#!/bin/bash
expect -c '
spawn... (2 Replies)
hi all,
i have made a shell script and it runs until it reaches the if statement, doesn't the ! mean only if the command fails it will echo me that message and then exit
can anyone please help me what is wrong with my code?
many thanks,
rob
#!/bin/bash
echo "is this archive... (10 Replies)
Hi,
I am a newbie to unix, I am trying to write a shell script (just a test) but I can't seem to compare the variable value with a string in the if statement.
I get an error when i execute the following script, could you tell me what is wrong and how I can correct it
Note - I am using bash... (4 Replies)
Hi,
As per my understanding, we can use two shebang statements in a single shell script. Please see below snippet-
#!/bin/bash
.......## some code A
#!/bin/csh
.......## some code B
exit 0;
Here, code A will be executed using bash shell and code B will be executed with c shell.
... (9 Replies)
I am writing a script that does a search for a argument in a file and lists all like occurrences. The script verifies that it is a file and then runs another script that list the lines. My problem is that I need the script to accept a file or a directory and then go to that directory check all... (1 Reply)
Good morning all!
I want to know if Im interpreting this if statement below right.
if(((1) || (0)) && (1)){
do stuff;
}
This is saying: if true piped into false, then true, then do stuff. Right?
What does the && stand for?
thanks in advance!
ben (3 Replies)
Hello members,
I'm working on the Solaris environment and the DB i'm using is Oracle 10g.
Skeleton of what I'm attempting;
Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a... (4 Replies)
I had different problem scenarios with IF statement. Can any expert please enlighten me on the difference with these scenarios. Thank you.
1st Scenario:
testdate=`date +%Y%m`
test=`cat /var/log/database0.$testdate*.log | grep "Errors found during processing" | tail -10`
if
then
... (4 Replies)
Sorry to be a pain, but how does the else work in the if statements?
Ive been making scripts with if statements but i cant get the else statements working.
Can you help? (8 Replies)
I have a shell script which resides on three SCO machines containing some simple sqlplus statments. I need to run these scripts remotely. Currently, I am trying to use rsh to do so:
rsh hostname myscript args
The problem is that the arguments to the sqlplus statements in the remote shell... (4 Replies)