LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-12-2002, 06:28 PM   #1
Xyphoid
LQ Newbie
 
Registered: Jan 2002
Posts: 2

Rep: Reputation: 0
Angry Scripts won't run commands


I'm working on a sig generator install file that will do everything you need to get my random sig generator working. The problem is that one of my scripts won't run. Full text is as follows:

#!/bin/sh
rm -f ~/.signature
~/.random/sig > ~/.signature

The last two lines run fine when I execute them manually in an xterm. I also tried sourcing the last two lines. A script gives me the error:

bash: ./change: bad interpreter: No such file or directory

(Filename is "change") Any ideas as to why this happens and how I can fix it?


Thanks.
 
Old 01-12-2002, 07:02 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 245Reputation: 245Reputation: 245
did you make sure the file is executable with chmod command.. ??
 
Old 01-12-2002, 07:26 PM   #3
Xyphoid
LQ Newbie
 
Registered: Jan 2002
Posts: 2

Original Poster
Rep: Reputation: 0
Yep

It executes, as I've got it chmoded to 755, but the shell gives me that error.

I also copied it to another filename and chmoded it to 6xx, then did:

source <filename>

But it gave me an error as well.
 
Old 01-14-2002, 03:27 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
I think that depends on which shell or version of linux/unix you are using. I tried it in linux with the bash shell and there the ~ was recognized. But I also tried it on a Digital Unix system with the korn shell and there it gave an error saying ~ is unknown. You could try either using the full path or ommiting the first line which makes it start a new shell which doesn't have the ~ set.
 
Old 08-08-2002, 08:49 PM   #5
namelocr
LQ Newbie
 
Registered: Aug 2002
Posts: 6

Rep: Reputation: 0
Don't know if anyone made this discovery yet....

I had the same problem and made the following discovery
about the script I was trying to execute but was receiving the 'bad interpreter' message (Redhat Linux 7.3].
The script looked fine when I opened it in vi, btw.
and I could execute the script fine by calling it directly with
perl (it was a perl script).

When you invoke vi in Linux, the editor "vim" is invoked
(because of the alias vi=vim).
vim recognizes both dos and unix file formats.
When I vi'd the file, it appeared fine but the
fileformat (when you first open) stated the file was [dos].
I issued command ":set fileformat=unix" in vi (vim) and
saved. After that, the script ran fine.

Bottom line is the file hae the dos end-of-line character(s) instead
of the unix newline. I guess Perl handles the dos format but bash
does not.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i run a shell scripts (or a number of commands )when a user logs in to a linu rddreamz Programming 4 05-20-2004 03:08 PM
how to make/run startup scripts/commands ViN86 Slackware 3 04-24-2004 10:02 AM
Running Scripts/Commands on Startup drknow Linux - Newbie 4 01-09-2004 05:14 AM
Linux commands in shell scripts james_cwy Linux - Newbie 4 11-10-2003 01:14 AM
Running ftp commands in scripts john lee Linux - Newbie 4 05-07-2003 12:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration