DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Thanked 1 Time in 1 Post
Default Bash script cannot execute - Is a directory

Whenever I execute a bash script, I get this error:

Code:
$ ./script.sh  
hello world
./script.sh[3]: /home/guitarscn: cannot execute - Is a directory
Here is the script:
Code:
#!/bin/ksh
echo "hello world"
Why is this?
Reply With Quote
  #2   (View Single Post)  
Old 6th November 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,116
Thanked 182 Times in 149 Posts
Default

It is not a bash script, it is a ksh script. Do you have a 'ksh' in /bin?
Code:
$ ls -l /bin/ksh
-r-xr-xr-x  3 root  bin  410744 Apr  4  2010 /bin/ksh
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Thanked 1 Time in 1 Post
Default

Whoops, I meant it was a ksh script, sorry, a bit used to bash scripting

Code:
$ ls -l /bin/ksh
-r-xr-xr-x  3 root  bin  384084 Aug 16 10:48 /bin/ksh
Yea, I made sure it was there beforehand
Reply With Quote
  #4   (View Single Post)  
Old 6th November 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,051
Thanked 198 Times in 156 Posts
Default

Quote:
./script.sh[3]: /home/guitarscn: cannot execute - Is a directory
This says the error occurs at line 3, but there are only two lines in the script you posted (...?)
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #5   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Thanked 1 Time in 1 Post
Default

Yea, I don't have a newline there either...this is what I don't understand

If you're on OpenBSD (4.8-Release for me) could you try making the same script and see if it reproduces the same error?
Reply With Quote
  #6   (View Single Post)  
Old 6th November 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,116
Thanked 182 Times in 149 Posts
Default

Assuming the execute has been set, you could check whether you not accidently entered some control characters
Code:
$ hexdump -C script.sh
00000000  23 21 2f 62 69 6e 2f 6b  73 68 0a 65 63 68 6f 20  |#!/bin/ksh.echo |
00000010  22 68 65 6c 6c 6f 20 77  6f 72 6c 64 22 0a 0a     |"hello world"..|
0000001f
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #7   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Thanked 1 Time in 1 Post
Default

Okay, I just deleted the file and made a new file, and now suddenly it works...must've been something invisible. I'm kind of curious as to what it was but it seems to be fine now.
Reply With Quote
  #8   (View Single Post)  
Old 6th November 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,051
Thanked 198 Times in 156 Posts
Default

If you had done a hexdump as j65nko suggested we might have known
Maybe there is still a backup file in /tmp?
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #9   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Thanked 1 Time in 1 Post
Default

Mmm...nothing there except a couple X-related files and an xmms dump
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] How to make 2 separate arguments in 1 bash script? guitarscn Programming 1 31st August 2010 09:12 PM
Writing a simple script to edit text files and execute commands guitarscn Programming 11 24th August 2010 09:21 PM
strange "~" directory in home directory gosha OpenBSD General 5 23rd February 2009 06:12 PM
execute commands from xinitrc rex FreeBSD General 3 22nd October 2008 10:24 PM
Cron won't execute a perl script ivanatora FreeBSD General 4 17th August 2008 07:53 AM


All times are GMT. The time now is 11:45 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick