LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-23-2009, 10:52 AM   #1
jbwells7474
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Rep: Reputation: 0
simple shell file


Hi -

I'm completely new to writing the shell files to run in batch.
It seemed to be completely straight forward, and I wrote the following file: simpTask.sh

#!/bin/bash
echo 'hello world'


then saved it, then made it an executable

chmod a+rx simpTask.sh

then tried to run it

./simpTask.sh

and got the following message

"cannot execute binary file"

any help would be greatly appreciated.

J
 
Old 08-23-2009, 11:00 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
What editor did you use to create the file? Was it created by a windows application?
Welcome to LQ!
 
Old 08-23-2009, 12:40 PM   #3
jbwells7474
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Windows notepad....saved as an ascii file.
 
Old 08-23-2009, 12:42 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The guess by tredegar was good! The problem arises due to the different line terminators used by windows and unix systems (details here). Try the command
Code:
dos2unix simpTask.sh
then run the script again.
 
Old 08-23-2009, 12:45 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Then you might need to use dos2unix to convert it to the unix format. Or just use a linux text editor to create it, or an editor that can save the files with linux line endings. DOS/Win uses carry return AND line feed to mark a new line, Unix/Linux use just a line feed character.
 
Old 08-23-2009, 12:50 PM   #6
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298
Blog Entries: 61

Rep: Reputation: Disabled
Quote:
Originally Posted by i92guboj View Post
or an editor that can save the files with linux line endings.
EditPad Lite is one that I know of that can do that.

http://www.editpadpro.com/editpadlite.html
 
Old 08-23-2009, 12:54 PM   #7
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Suitable editors for writing scripts / programs:
kate kwrite (if using KDE)
nano vi vim (if using a terminal)
But there are 100's more.

What's the gnome default GUI editor? I forget.

Now who is going to complain that I haven't mentioned ..... ( emacs comes to mind )
 
Old 08-23-2009, 12:55 PM   #8
joeBuffer
Member
 
Registered: Jul 2009
Distribution: Ubuntu 9.04
Posts: 328

Rep: Reputation: 42
The GNOME editor is gedit.

Last edited by joeBuffer; 08-23-2009 at 01:30 PM.
 
Old 08-23-2009, 12:56 PM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by tredegar View Post
What's the gnome default GUI editor?
gedit
 
Old 08-23-2009, 01:00 PM   #10
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298
Blog Entries: 61

Rep: Reputation: Disabled
Quote:
Originally Posted by tredegar View Post
Now who is going to complain that I haven't mentioned ..... ( emacs comes to mind )
Go on then, I'll do it.
Hey, why haven't you mentioned Emacs?
 
Old 08-23-2009, 01:02 PM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by brianL View Post
Go on then, I'll do it.
Hey, why haven't you mentioned Emacs?
He did
 
Old 08-23-2009, 01:05 PM   #12
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298
Blog Entries: 61

Rep: Reputation: Disabled
Oh yes...
 
Old 08-23-2009, 01:24 PM   #13
jbwells7474
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Original Poster
Rep: Reputation: 0
dos2unix on file didn't change the outcome -- still could not open

downloaded editpad lite, saved as unix file, ./simpTask.sh results in "file not found" but vi simpTask.sh shows file

xwin won't allow me to open nedit -- and before resorting to using vi, or one of those text editors that I find painful, I thought i'd fish around to see if there were any other ideas.
 
Old 08-23-2009, 01:26 PM   #14
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298
Blog Entries: 61

Rep: Reputation: Disabled
I thought you wanted a text editor for Windows, that's why I mentioned EditPad Lite.
P.S.
Ooops, just reread your post again.

Last edited by brianL; 08-23-2009 at 01:28 PM.
 
Old 08-23-2009, 01:39 PM   #15
jbwells7474
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Original Poster
Rep: Reputation: 0
ideally, i would prefer to do it in windows...and i did download editpro to windows...and i thought i saved the file as linux, but evidently i failed
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
converting a c shell file to a bash shell file anindyarc Linux - Newbie 2 05-11-2009 03:26 PM
LXer: Simple Shell One-Liner To Enumerate File Types In Linux and Unix LXer Syndicated Linux News 2 05-30-2008 08:47 AM
Need help getting started simple simple shell script dhonnoll78 Programming 6 12-17-2007 05:34 PM
Anyone know of a very very simple shell? blackzone Programming 3 07-08-2006 09:38 PM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:17 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
Open Source Consulting | Domain Registration