Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 12th, 2005, 10:45 AM   #1
satimis
Newbie
 
Join Date: Oct 2004
Posts: 17
Rep Power: 0 satimis is on a distinguished road
A simple perl script

Hi folks,

I'm prepared to write a simple perl scripts as follow

There are 25 commands executed in following sequence
export LFS=/mnt/lfs
mount /dev/hda6 /mnt/lfs
mkdir -p $LFS
echo $LFS
/mnt/lfs (output)
/usr/sbin/chroot "$LFS" /tools/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ '     PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h
mknod -m 600 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mount -n -t tmpfs none /dev
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
chown root:tty /dev/{console,ptmx,tty}
ln -s /proc/self/fd /dev/fd
ln -s /proc/self/fd/0 /dev/stdin
ln -s /proc/self/fd/1 /dev/stdout
ln -s /proc/self/fd/2 /dev/stderr
ln -s /proc/kcore /dev/core
mkdir /dev/pts
mkdir /dev/shm
mount -t devpts -o gid=4,mode=620 none /dev/pts
mount -t tmpfs none /dev/shm

In normal circumstance there is no output on all commands except command-4 with "/mnt/lfs" as output. If not considering the output it will be quite simple just listing all commands on a shell script. Now I expect to arrange the script as follows;

1) The script will automatically continue to execute command-5 if the output of command-4 is "/mnt/lfs" otherwise exit the shell.
2) If there is an output on any command it needs to confirm "yes/no" with the corresponding command displayed on the terminal. 'yes" will continue on next command. "no" will exit the shell stopping the script.

I'm considering whether shell script or perl script will do the job better. If perl script then how to start. Which module/modules will be more appropriate, TIA

B.R.
satimis
satimis is offline   Reply With Quote
Old Aug 12th, 2005, 1:28 PM   #2
prolog
Programmer
 
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4 prolog is on a distinguished road
Hi,

my suggestion is: go for bash/sh/csh - script or whatever shell u use. There is now advantege using perl here, except you want to implement things like mount, mkdir, mknod etc. yourself in perl. Otherwise you just fork off the processes and pipe data.
The same goes for shell-script with the difference that there is no additional perl-process iz running. Besides for this tasks perl is just oversized (hmm does one call it like that ?).

So far ...
__________________
-= C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do succeed, you will blow away your whole leg. =- Bjarne Stroustrup
prolog is offline   Reply With Quote
Old Aug 13th, 2005, 12:23 AM   #3
satimis
Newbie
 
Join Date: Oct 2004
Posts: 17
Rep Power: 0 satimis is on a distinguished road
Hi prolog,

Your advice noted thanks.

I made it on Shell but still having some minor features needed to add. I just tried to see whether perl will be more appropriate for this simple script. OR there are better solutions

B.R.
satimis
satimis is offline   Reply With Quote
Old Aug 15th, 2005, 9:31 AM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Since this script is basically a sequence of commands, I agree that it would be best written in a shell script such as /bin/sh.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC