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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error Message chapmana UNIX for Dummies Questions & Answers 5 11-29-2006 11:41 AM
Error Message RDM00 UNIX for Dummies Questions & Answers 2 10-06-2006 07:43 PM
Error message ghuber UNIX for Advanced & Expert Users 1 11-14-2005 06:04 AM
error message vnc Castelior UNIX for Advanced & Expert Users 3 10-21-2004 05:50 AM
error message alisev UNIX for Dummies Questions & Answers 3 01-08-2002 05:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-22-2003
Latha Nair Latha Nair is offline
Registered User
  
 

Join Date: Sep 2003
Location: Pennsylvania, USA
Posts: 25
Arrow CSH Error Message

Hi,

I am new to unix, and trying to create a simple script called "nightjobs"

set TODAY=`date +"%m%d%y"`
echo -n "Please enter your Initials (3 alpha characters): "
read init
for GROUP in 4 5
do
set logfile="/home/OPER/LOGS/nightjobs"$GROUP"-TODAY".log"
set filnam="daily"$GROUP"-"$TODAY
echo "Night jobs started: " $TODAY >$logfile
< Here I have the commands to do the nightjobs >
done

When I try to run this script, I get the following error message:

# ./nightjobs
Please enter your Initials (3 alpha characters): KLN
for: Command not found.
do: Command not found.
GROUP: Undefined variable.

What am I doing wrong? Please help. My first line in the script is
#!/bin/csh -f

Thank you.
Latha Nair
  #2 (permalink)  
Old 10-22-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
"for" and "do" are from sh, ksh, bash, or something like that. It looks like you wrote a sh script and carefully send it to csh to be run. Change the first line of your script to a shell that can run it. Or translate it into csh. csh has a foreach statement I think, but I'm not a csh expert.
  #3 (permalink)  
Old 10-22-2003
Latha Nair Latha Nair is offline
Registered User
  
 

Join Date: Sep 2003
Location: Pennsylvania, USA
Posts: 25
It works in ksh. I was trying to use csh because it can put the cursor right after the question
echo -n "Please enter your Initials (3 alpha characters): "
and let the user type in their initials. When I used ksh, it takes the cursor to the next line. I know this is not a big deal, but I just wanted to leave the cursor right after the endquote.

I will see if I can get any additional information on the 'foreach' statement.

Thank you for your help.
Latha Nair
  #4 (permalink)  
Old 10-22-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
The echo statement can have varying syntax. The best thing to do in ksh is switch to print when you care.

print -n "Enter value - "
  #5 (permalink)  
Old 10-22-2003
Latha Nair Latha Nair is offline
Registered User
  
 

Join Date: Sep 2003
Location: Pennsylvania, USA
Posts: 25
wOw......... Things are sure easy when you know what you are doing. Thanks a bunch! That works for me, and that was all I was trying to accomplish.

This site is great!
Latha Nair
  #6 (permalink)  
Old 10-22-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
Quote:
Originally posted by Latha Nair
Things are sure easy when you know what you are doing.
That is almost my personal motto. (I reverse words 2 and 3). I plan to have that carved into my tombstone.
  #7 (permalink)  
Old 10-22-2003
Latha Nair Latha Nair is offline
Registered User
  
 

Join Date: Sep 2003
Location: Pennsylvania, USA
Posts: 25
Unfortunately (or fortunately), we don't have tombstones! We get cremated! So, I guess whatever I have to say would be cremated with me!

My conclusion is that all the manuals, help routines , everything that is meant to make things easier...... makes sense only when you know the stuff (at least most of the time). I get better tips from people who have worked with the stuff (like I am doing now). I am slowly getting better, as each day goes by. We just have been up on Unix barely a month. I have only OpenVMS knowledge, which is NO GOOD at this point! I guess we have to roll with the punches (as they say?) I will keep a watch on this site for helpful information. I did go thru a lot of emails from folks like me - struggling with some day to day stuff.

Thanks again.....for your help. It is much appreciated.

Latha Nair
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0