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
Help! Problem with Shell Script. pektl Shell Programming and Scripting 7 05-29-2006 02:08 AM
Problem with SU or SSH in shell script sravanp UNIX for Dummies Questions & Answers 2 01-24-2006 08:00 AM
Shell Script problem bnohifi Shell Programming and Scripting 1 07-06-2005 11:02 PM
Problem with shell script zylwyz Shell Programming and Scripting 2 06-29-2005 10:01 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-24-2007
Registered User
 

Join Date: Apr 2007
Posts: 17
Problem In Shell Script

Hi,

I'm new to Shell script. Can anyone tell me where is the wrong in my code?

And, my code is --


Code:
echo "Enter Start Date(YYYY-MM-DD): "
read stdt 


echo "Enter End Date(YYYY-MM-DD): "
read endt 

echo "Enter Flight Number(Optional): "
read fln


echo "Enter Output XML File Name(Including Extension): "
read dst

#if [ $fln eq "" ] then
#if [ "$fln" = "" ] then

if [ $? -lt 3 ] then
   java DailyScheduleExport $stdt $endt> $dst
else
   java DailyScheduleExport $stdt $endt $fln> $dst
fi
Waiting for your reply.

And the error is --

Code:
ods@awhq6640[/prod/ods/sqlj/ods_services]>sh DailyScheduleExport_q.ksh
DailyScheduleExport_q.ksh[2]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[4]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[6]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[8]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[9]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[12]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[13]: ^M: Execute permission denied.
Enter Start Date(YYYY-MM-DD):
2007-01-01
DailyScheduleExport_q.ksh[16]: ^M: This is not an identifier.
DailyScheduleExport_q.ksh[17]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[18]: ^M: Execute permission denied.
Enter End Date(YYYY-MM-DD):
2007-09-21
DailyScheduleExport_q.ksh[20]: ^M: This is not an identifier.
DailyScheduleExport_q.ksh[21]: ^M: Execute permission denied.
Enter Flight Number(Optional):
DailyScheduleExport_q.ksh[23]: fln^M: This is not an identifier.
DailyScheduleExport_q.ksh[24]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[25]: ^M: Execute permission denied.
Enter Output XML File Name(Including Extension):
DailyScheduleExport_q.ksh[27]: dst^M: This is not an identifier.
DailyScheduleExport_q.ksh[28]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[31]: ^M: Execute permission denied.
DailyScheduleExport_q.ksh[32]: Syntax error at line 32 : `if' is not matched.
ods@awhq6640[/prod/ods/sqlj/ods_services]>
And, the file status is --

Code:
-rwxrwxrwx   1 ods        ods            800 Sep 24 06:28 DailyScheduleExport_q.ksh
What might be the problem? Any suggestion?

Regards.

Satyaki De.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-24-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,643
Can you post the output of this command

Code:
head -1 <your_shell_script_name> | od -a
Perhaps that must be because of the ctrl-m characters in the shell script. Run a dos2unix on your shellscript and then run it.

Also put #! /bin/ksh as the first line of your shell script.
Reply With Quote
  #3 (permalink)  
Old 09-24-2007
Registered User
 

Join Date: Apr 2007
Posts: 17
Hi thanks for your reply. But, it is showing error message --

Code:
ods@awhq6640[/prod/ods/sqlj/ods_services]>tput clear
ods@awhq6640[/prod/ods/sqlj/ods_services]>head -1 DailyScheduleExport_q.ksh | od -a
od: illegal option -- a
Usage: od [-v] [-A base] [-j skip] [-N count] [-t type_string]... [file...]
ods@awhq6640[/prod/ods/sqlj/ods_services]>
I've already added this line in my shell -

Code:
#!/usr/bin/ksh
Regards.

Satyaki De.
Reply With Quote
  #4 (permalink)  
Old 09-24-2007
Registered User
 

Join Date: Jan 2002
Location: Pennsylvania
Posts: 3
Hi,

Looks like you may have extraneous "Control-M" characters in your file. Open it in vi to see. This occurs sometimes when porting a DOS/Windows file to Unix. You can delete them one by one or run the command: dos2unix. If your OS doesn't have this command look for one by typing: man -k dos.

Hope this helps,

John
Reply With Quote
  #5 (permalink)  
Old 09-24-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,643
Which OS are you on ? Post the output of uname -a.

Do you have dos2unix on your machine ? If so, try running dos2unix on the shellscript.
Reply With Quote
  #6 (permalink)  
Old 09-24-2007
Registered User
 

Join Date: Apr 2007
Posts: 17
Thanks for your reply. OS information is as follows -

Code:
HP-UX awhq6640 B.11.11 U 9000/800 665379313 unlimited-user license
Regards.

Satyaki De.
Reply With Quote
  #7 (permalink)  
Old 09-24-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,643
Quote:
Originally Posted by satyakide View Post
Code:
HP-UX awhq6640 B.11.11 U 9000/800 665379313 unlimited-user license
So you must be having dos2ux on your system. Run
Code:
dos2ux DailyScheduleExport_q.ksh
and then try running the script.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:59 PM.


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

Content Relevant URLs by vBSEO 3.2.0