How can i check my code ..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can i check my code ..
# 1  
Old 08-08-2006
CPU & Memory How can i check my code ..

HTML Code:
#!/bin/sh
#For Daily Routine
echo 'Checking in Progress ...'
echo > status.txt
echo >> status.txt
for i in IVR011 IVR012 IVR021 IVR022
do
echo >> status.txt
echo ' ****** '$i ' *******' >> status.txt
echo >> status.txt
rsh $i df -k >> status.txt
echo >> status.txt
rsh $i sar 1 5 >>status.txt
echo >> status.txt
rsh $i ppaid check all >> status.txt
echo >> status.txt
done
echo 'done'
Well given above is my lil effort which is quite self explanatory , now i need to ask is .. is there someway that i can check my code ( for errors ) before running it on actual server ?
and also since in this code i m using "rsh" .. which do sometimes prompt for username and password .. can i add these two parameters in my code with every "IVR"..if yes .. how ?
waiting for reply .
regards
# 2  
Old 08-09-2006
I don't remember about varsions of sh, but I think at some point more modern Bourne shell supports:
Code:
#place this just below the magic number (1st) line
set -n

This just checks syntax, it executes nothing. If it does not work for you change to #!/bin/ksh for a test.

The HPUX 11.0 version of /bin/sh supports it at any rate... and it was first shipped in the 1990's.
# 3  
Old 08-09-2006
Well i just checked that how many shells i have on my system . it prompted like
/sbin/sh
/bin/tcsh
/bin/true

and i work in "tcsh" which is C shell perhaps ... does this shell support any sort of debugging ... besides .. does this code make a logic to you ... i mean i m just thinking hard that if i could check it on system or not ..
Regards
# 4  
Old 08-09-2006
I don't know csh or tcsh.

set -n is designed to check syntax - what you asked. You have sh which will probably do. Try it. Try it at the command prompt when you are in sh.
Code:
sh
set -n
exit

If set -n is not allowed, then you will get an error after the set -n command. It should be okay...
# 5  
Old 08-09-2006
Thanks .. this is fine and fortunately i have found a workstation to play with aswell :-D

HTML Code:
rsh $i df -k >> status.txt
echo >> status.txt
Now just take look at these two lines of code .. they are working fine ..but i want a lil more .. well after rsh it should follow these steps
su - ops
cd severe
show tsp

and store the output of "show tsp" in same 'status.txt'

regards
# 6  
Old 08-10-2006
I m still waiting for someone's help .. Smilie
i only need to these these steps in my script in same order

su - xyz
cd Useraccount
show tsp

and store output of "show tsp" in 'status.txt'
regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with code to check if file systems are mounted

Hi I need to have a piece of code that check if all file systems are mounted or not. I have to pieces of information like the output of the bdfcommand, and the file /etc/fstab. The first is: bdf Filesystem kbytes used avail %used Mounted on /dev/vg00/lvol3 2097152 266656... (3 Replies)
Discussion started by: fretagi
3 Replies

2. Shell Programming and Scripting

Check wget return code

hello check this script it jump to else part, in n both cases, (if files exist or not) wget $MIRROR/kkk.zip && wget $MIRROR/jjj.zip RC="$?" if ] then echo -e "$RED Ooops, Download links are broken...! $RESET" else echo -e "$GREEN Everything is fine, Cheers ... $RESET" fi (4 Replies)
Discussion started by: nimafire
4 Replies

3. Shell Programming and Scripting

Perl code to check date and check files in particular dir

Hi Experts, I am checking how to get day in Perl. If it is “Monday” I need to process…below is the pseudo code. Can you please prove the code for below condition. if (today=="Monday" ) { while (current_time LESS THAN 9:01 AM) ... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies

4. Shell Programming and Scripting

PERL code to check if file exists

Hi Guy’s, I have this simple PERL code which checks whether the file exists . At the moment I am getting the following error This is the code I am using #!/usr/bin/perl Open (F, "home/work/PerlWork/dataFile") or die "Could not open the file:$!\"; Also how can I read the content of... (3 Replies)
Discussion started by: INHF
3 Replies

5. Shell Programming and Scripting

Find: return code check

Hi, I've a find command like, find /abcd/efgh -name "xxxx" 2> /dev/null > file1 what would be the condition to check if this returns none(means if the file "xxxx" is not present) ???? I tried checking with $? and it returns 72 to me but even the file is present also it returns... (6 Replies)
Discussion started by: skcvasanth
6 Replies

6. Shell Programming and Scripting

please check this code

hi, i m checking the directory is empty or not FILE="" DIR="/ann/a1" if ; then echo "$dir is not Empty" else echo "$dir is Empty" fi i m always getting this directory is not empty, even if the directory is empty please point where i had went wrong?? (6 Replies)
Discussion started by: angel12345
6 Replies

7. Programming

c++ code to check whether a list is circular or not

hi all, i need c++ code to check whether a list is circular or not... please help (8 Replies)
Discussion started by: vidyaj
8 Replies

8. Shell Programming and Scripting

Mail::Sender - How to Check Result Code?

I have a code block which sends a mail using Mail::Sender. Everything works great now. I just want to know how to check whether the status of sending mail is success or failure. Based on which I will log the result in my log file. How can I do this? Any idea please? (2 Replies)
Discussion started by: dahlia84
2 Replies

9. Web Development

[PHP] Server Check and Failover Code

Here is some sample PHP code you can run if you have a PHP web application that uses code or images from an ad server, image server, or content deliver network, and you want to check if it is working and if not, failover to another one: <?php $current_server = "server.domain.com"; // set... (0 Replies)
Discussion started by: Neo
0 Replies

10. UNIX for Dummies Questions & Answers

check my code?? running shell from c?

Hi mates, i am trying to run a shell command from my C program in this case let is say the "ls" command. It copiles it okay, and even creates the new fork too. But seems to nothing is happening i mean it is not showing the result of the "ls" command. I don't know wat i am doing wrong. Any... (1 Reply)
Discussion started by: abdul
1 Replies
Login or Register to Ask a Question