ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
# determine number of rooms at property
SQLCMD="SELECT COUNT(*) FROM kc_client_parameter WHERE room_nbr < 9999;"
ROOMCOUNT=`echo $SQLCMD | $SQLPRG | tail -n 1` && debug "ROOMCOUNT=$ROOMCOUNT"
# determine total room nights occupied
SQLCMD="SELECT SUM(occupancy) FROM kc_occupancy_rate WHERE timestamp BETWEEN DATE_ADD(CURRENT_DATE, INTERVAL -1 MONTH) AND CURRENT_DATE;"
# total available room nights
#1 get number of days in the previous month
SQLCMD="SELECT DAYOFMONTH(DATE_ADD(CURRENT_DATE, INTERVAL -1 DAY));"
DAYS=`echo $SQLCMD| $SQLPRG | tail -n 1` && debug "DAYS=$DAYS"
#2 count total available room nights
ROOMNIGHTS=`expr $ROOMCOUNT "*" $DAYS` && debug "ROOMNIGHTS=$ROOMNIGHTS"
bash is either not installed or is installed in a different location than /bin/bash. e.g. on *bsd it may install to /usr/local/bin/bash, or not be installed at all.
env | grep SHELL and let us know what shell you are running.
How did you create the shell...ie. on pc and then ftp or vi on linux...
If you do a vi <shell name> do you see it open in dos mode...you can see this at the bottom of the screen...
It will look something like this....
"Makefile" [dos] 773L, 35163C
I just re-installed Suse linux 8.0 on my box and I am getting the bad interpreter message no matter what scripting language I use and it doesn't matter where I put the script.
#!/usr/bin/perl
#!/bin/bash
etc...
I checked my /etc/fstab file and everything is pretty much set to 'Defaults', which I believe is rw,exec, blah blah. I don't think that the problem resides there. Is there some configuration script that I need to run in order to associate each interpreter with the file type? The shell should read the first line and figure out what interpreter to use right? I have to manually type in 'perl example.pl' in order for it to run. I changed the permission of scripts to chmod 777 and still no luck. Any ideas here???
Here's a subtle cause for the same problem; doesn't necessarily sound like your situation though.
I move a massive ksh shell script between work and home. By the time I get the file to my Linux system (via Outlook mail, my PC, etc). I end up with DOS carriage returns embedded within the script. VIM hasn't revealed these with ^Ms so I sometimes don't immediate realize what has occurred.
This can be confirmed by using "od"
Code:
od -x | more
If there are 0x0a 0x0d pairs then this will cause the command interpreter to choke with "bad interpreter."
Solution: make sure that you aren't doing a binary transfer of a DOS file. On the target system you can strip them out using many techniques; here's one example:
I changed permissions on my scripts to 'wide open' rwxrwxrwx and I wrote the scripts using kwrite, so it shouldn't have put those weird carriage return chars on the end. I also use nedit, an editor written in motif that will show the <CR> characters and these scripts just don't have it. I have a couple of unix admins here at work scratching their heads too. I'm stumped.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.