LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-13-2010, 03:04 AM   #1
eliote
Member
 
Registered: Jun 2010
Distribution: Ubuntu
Posts: 39

Rep: Reputation: 0
bash script problem


Hi all,

I'm observing a problem which makes my script stop to run. the problem is when I copy the script into a new machine (ubuntu-server), and try to run the script the kernel stops it from running and throw an error.
I don' really know what the problem is; but when i write the script in that machine using vi editor, the script runs properly...

any idea about the problem?
 
Old 10-13-2010, 03:11 AM   #2
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: RHEL/Ubuntu/Debian/Fedora/Centos/K3OS
Posts: 1,159
Blog Entries: 4

Rep: Reputation: 149Reputation: 149
Thumbs up

Quote:
Originally Posted by eliote View Post
Hi all,

throw an error.
Let us know the exact error.

let us know the if the copied file has executable permission

also check it using

ls -ld scriptname.sh
 
Old 10-13-2010, 03:13 AM   #3
T0sh1r0
Member
 
Registered: Oct 2010
Posts: 51
Blog Entries: 1

Rep: Reputation: Disabled
What's the error message you get?
Hard to guess without that... Maybe hidden character?
 
Old 10-13-2010, 03:13 AM   #4
ionrivera
Member
 
Registered: May 2010
Distribution: Debian, RHEL, AIX, Solaris, HP-UX
Posts: 61

Rep: Reputation: 4
what's the error? did you check the file permission of the script after you have transferred it on a different machine e.g.(ubuntu-server)?
 
Old 10-13-2010, 03:39 AM   #5
eliote
Member
 
Registered: Jun 2010
Distribution: Ubuntu
Posts: 39

Original Poster
Rep: Reputation: 0
Report

Quote:
Originally Posted by prayag_pjs View Post
Let us know the exact error.

let us know the if the copied file has executable permission

also check it using

ls -ld scriptname.sh
the script does not have .sh extention at the end exactly! but, yes I gave the owner suffice permissions to execute.
 
Old 10-13-2010, 04:06 AM   #6
dr_agon
Member
 
Registered: Sep 2007
Location: Poland
Distribution: Ubuntu LTS
Posts: 105
Blog Entries: 12

Rep: Reputation: 26
It may sound silly, but since v. 6.10 the default shell after installation is dash, not bash, and it caused some problems to my scripts when they were not explicitely evoked with bash.
Judging from the title of this post you prepared the script for bash, maybe your other machine has dash as default shell?
 
Old 10-14-2010, 03:42 PM   #7
cheesus
Member
 
Registered: Jan 2005
Location: Munich, Germany
Distribution: SuSE
Posts: 186

Rep: Reputation: 25
Exclamation

actually, every shell script should specify it's desired run shell
in the first line, as in
Code:
#!/bin/bash
echo "this is to be ran in bash, not dash, not tcsch, or anything"
 
  


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
Bash script problem with ftp session exiting the script early edomingox Programming 5 02-23-2010 05:39 AM
[SOLVED] bash : getopts problem in bash script. angel115 Programming 2 03-02-2009 10:53 AM
bash script problem noir911 Programming 1 01-21-2006 05:02 PM
bash script problem fatbastard spice Linux - General 2 08-24-2005 02:15 AM
Bash script problem kalleanka Programming 2 01-30-2004 11:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:22 AM.

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