LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 10-03-2014, 05:17 PM   #1
jazzo
Member
 
Registered: Jul 2012
Posts: 192

Rep: Reputation: Disabled
script won't execute


Hello all,
I have just created the text1.sh script with notepad in ubuntu containing the following code:
Code:
!#/bin/bash
read -p "Enter your name: " name
echo "Hi, $name, let's be friends!"
then I changed the permissions and executed it:
Code:
antobbo@antobbo-linux-Dell-System-XPS-L702X:~/Desktop$ ./test1.sh
but whatever I type at the prompt after I click enter I receive the following message:
Code:
: No such file or directorybash
Enter your name: baost
': not a valid identifier `name
Hi, , let's be friends!
antobbo@antobbo-linux-Dell-System-XPS-L702X:~/Desktop$
I'm kind of wondering what it is that I've done wrong...any idea?
thanks
 
Old 10-03-2014, 05:28 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,825

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
Quote:
created the text1.sh script with notepad
???
Notepad ?
as in Microsoft's Notepad ?

then the FIRST thing you need to do is run
"dos2unix" on it to remove the MICROSOFT line endings

then you will likely need to look at it is gedit,kate,kwrite,vi,emacs,....
to make sure that it is not royally messed up from he Microsoft formatting
 
Old 10-03-2014, 06:28 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,938

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
And...
Quote:
!#/bin/bash
Should be
Quote:
#!/bin/bash
 
Old 10-04-2014, 05:57 AM   #4
jazzo
Member
 
Registered: Jul 2012
Posts: 192

Original Poster
Rep: Reputation: Disabled
Thanks guys:
@John VV: no not microsoft, I'm on ubuntu 12.04...but now that you say that, notepad probably runs on wine...um.
@michaelk: thanks for spotting that, apologies, I'll be more careful next time!
SO, I scrapped that file, installed emacs, done the script again and saved with a different name and now it works :-)
thanks guys for your help!
 
Old 10-04-2014, 08:44 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
Please mark as SOLVED once you have a solution
 
Old 10-04-2014, 09:12 AM   #6
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
Notepad saved the file as DOS format with CRLF. Bash doesn't understand that. Next time run dos2unix to clean the file.

jlinkels
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash/CGI script won't execute - error 500 Annielover Programming 6 07-02-2012 12:31 PM
[SOLVED] Source or Execute an external Script from shell script helptonewbie Linux - Newbie 2 08-11-2010 01:48 PM
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 03:41 AM
shell script won't execute brandnewbie Linux - Newbie 7 08-10-2004 02:30 PM
Firewall Script Won't Execute jimminy34 Linux - Security 3 02-02-2003 07:34 AM


All times are GMT -5. The time now is 04:08 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