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-29-2011, 02:22 PM   #1
napoli
LQ Newbie
 
Registered: Oct 2011
Posts: 2

Rep: Reputation: Disabled
How to call a script from a script?


My bash-script is this one:

Code:
#!/bin/bash
./flow3 kickstart:model Flow.Test MyClass title:string
if I append a new line to this script, e.g. to make it look like
Code:
#!/bin/bash
./flow3 kickstart:model Flow.Test MyClass title:string
./flow3 kickstart:model Flow.Test MyClass2 number:integer
then title:string[NEWLINE] is passed as an argument instead of title:string.
how do I fix this?
 
Old 10-29-2011, 02:35 PM   #2
JSkywalker
Member
 
Registered: Aug 2007
Distribution: openSUSE 12.1
Posts: 96

Rep: Reputation: 24
hmmm, if i have this:
Code:
#!/bin/bash
echo "#"$1"#"
echo "#"$2"#"
and this:
Code:
#!/bin/bash

./testje 1 2
./testje 3 4
than, when doing ./testje2, i will get:
Code:
#1#
#2#
#3#
#4#
which seems exactly as you expect....
 
Old 10-29-2011, 02:47 PM   #3
napoli
LQ Newbie
 
Registered: Oct 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Sorry, but how does this help?
 
Old 10-29-2011, 04:05 PM   #4
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Linux Mint, Ubuntu
Posts: 1,504

Rep: Reputation: 325Reputation: 325Reputation: 325Reputation: 325
It rules out bash as the problem.
 
Old 10-30-2011, 01:11 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
The symptom would happen if the script had edited using a Windows editor in which case the new line would have been made by ASCII "carriage return" followed by "line feed". Linux uses only "line feed" for a new line so bash would take the "carriage return" as the last character of the line. Wikipedia.

If that is what's happening, for a small file like this the easiest solution would be to use a Linux editor that shows the unwanted character and delete it. Alternatively you may have dos2unix or fromdos commands available or you could do it in an awk one liner:
Code:
awk '{ sub("\r$", ""); print }' flow3 > flow3.fixed
 
  


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
linux-backtrack- script that call to another script? yogevmi Programming 3 09-17-2010 06:35 AM
ssh - using variables in call to start remote script from local script babag Linux - Networking 2 06-03-2008 05:50 PM
How to call a script from a system startup script? jonatito Linux - Newbie 7 11-11-2005 10:40 PM
call another script and have the inital script exit mjtice Programming 1 09-11-2005 12:54 PM
My shell script can't seem to call another script kakho Programming 3 04-17-2004 10:21 AM


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