The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how i prepare a c++ code(c code) for implementing my own protocol format amitpansuria High Level Programming 1 09-06-2007 08:09 PM
Failed to check status code in "rsh" command nir_s Shell Programming and Scripting 9 07-03-2006 06:05 AM
SSH key code versus server key code Texan Security 1 04-12-2006 08:57 AM
Script to check for a file, check for 2hrs. then quit mmarsh UNIX for Dummies Questions & Answers 2 09-16-2005 11:46 AM
check my code?? running shell from c? abdul UNIX for Dummies Questions & Answers 1 09-03-2001 12:05 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-08-2006
Registered User
 

Join Date: Jul 2006
Posts: 47
Arrow 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
Reply With Quote
Forum Sponsor
  #2  
Old 08-09-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,266
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.
Reply With Quote
  #3  
Old 08-09-2006
Registered User
 

Join Date: Jul 2006
Posts: 47
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
Reply With Quote
  #4  
Old 08-09-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,266
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...
Reply With Quote
  #5  
Old 08-09-2006
Registered User
 

Join Date: Jul 2006
Posts: 47
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
Reply With Quote
  #6  
Old 08-09-2006
Registered User
 

Join Date: Jul 2006
Posts: 47
I m still waiting for someone's help ..
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0