LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-29-2009, 08:30 AM   #1
GNUJoshua
LQ Newbie
 
Registered: Jul 2008
Posts: 5

Rep: Reputation: 0
Bash Script bombs on embedded Linux system (Altiris)


I use a linux pre-installation environment to image workstations with Windows XP. This deployment product is Symantec's Altiris Deployment Solution. We are trying to build an automated installer that asks the tech questions, which will be inserted into the sysprep of the Windows system. We are trying to build DVD disks that will image for places without direct access to an altiris server.

And have a working way to drop down my image, which is good. What's bad is how built-in scripts are handled vs. typed commands...

To "make sure" these scripts would work, I created them after booting to the Linux environment from a Linux Managed altiris environment. Ran the scripts and they worked, just fine... so I committed them to the boot disk.

I get odd errors when trying to run the exact same scripts that I verified working by typing them in manually.

Here's an example of code from my script that is completely bombing out. This information is important because we manually modify our sysprep file when imaging (we have 5 domains and potential domain admins for joining):
Code:
#!/bin/bash
read -p "Enter DOMAIN to join " SNDOMAIN
read -p "Enter ADMIN USERID " SNUSER
read -p "Enter ADMIN PASSWORD " SNPASS
mkdir /dstemp
cat /mnt/atrsboot/sysprep.inf > /dstemp/xpprep.live
sed -e "s/SNDOMAIN/$SNDOMAIN/g" -i /dstemp/xpprep.live
sed -e "s/SNUSER/$SNUSER/g" -i /dstemp/xpprep.live
sed -e "s/SNPASS/$SNPASS/g" -i /dstemp/xpprep.live
/mnt/atrsboot/firm copy "/dstemp/xpprep.live" "prod:/Sysprep/sysprep.inf"
When testing this, as typed, the script would take the variables SNDOMAIN, SNUSER, and SNPASS and use sed to replace variables in the sysprep file, then it would insert the sysprep into the newly imaged system. I know this is a long post so I'll reiterate... the script worked FINE when typing the commands in manually.

Problem is, I'm getting errors that would hint towards a command interpreter or keyboard error... errors such as: (I've bolded manual input)
Code:
Enter DOMAIN to join mydomain.com
': not a valid identifier line 2: read: 'SNDOMAIN
Enter ADMIN USERID gnujoshua
': not a valid identifier line 3: read: 'SNUSER
Any clues are more than welcome... I've tried placing quotes around the variables "just in case", exact same result. I've also used the following:
Code:
echo "Please enter DOMAIN "
read SNDOMAIN
With the same result...

Last edited by GNUJoshua; 01-29-2009 at 08:32 AM.
 
Old 01-29-2009, 08:55 AM   #2
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
What is not really clear to me is: have you edited these files under windows or under linux? If you have edited the scripts under windows, most likely the line terminator is a carriage return which is not correctly managed by shell scripts in linux. I mean you have to convert them in Unix format prior to feed the shell with these script.

In Linux you can do this using the dos2unix command. Or eventually rewrite the scripts in a Linux environment using vi or any other available editor. I bet the problem magically disappear.
 
Old 01-29-2009, 09:41 AM   #3
GNUJoshua
LQ Newbie
 
Registered: Jul 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
What is not really clear to me is: have you edited these files under windows or under linux? If you have edited the scripts under windows, most likely the line terminator is a carriage return which is not correctly managed by shell scripts in linux. I mean you have to convert them in Unix format prior to feed the shell with these script.

In Linux you can do this using the dos2unix command. Or eventually rewrite the scripts in a Linux environment using vi or any other available editor. I bet the problem magically disappear.
I thought of that and am toasting a CD now to test. After opening the script up for editing in the Linux environment (using vi) I noticed the ^M after every line... I missed the CR's prior due to using cat to review the script.

Last edited by GNUJoshua; 01-29-2009 at 09:42 AM.
 
Old 01-29-2009, 12:15 PM   #4
GNUJoshua
LQ Newbie
 
Registered: Jul 2008
Posts: 5

Original Poster
Rep: Reputation: 0
THat was it, thanks colucix!
 
  


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
Porting linux to embedded system. swapnilborg Linux - Software 0 12-21-2005 04:31 AM
embedded bash in perl script paul_mat Linux - Software 3 11-21-2005 01:46 PM
make a bash script accesible from anywhere in the system osio Programming 9 09-20-2005 02:33 PM
Getting linux to boot on embedded system BleedingEdge Linux From Scratch 3 06-19-2005 06:36 AM
Does anyone know of a bash script that will determine if RPM exists on a system? jimwelc Linux - Software 3 12-28-2004 03:01 PM

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

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