LinuxQuestions.org
Review your favorite Linux distribution.
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 04-05-2006, 06:12 AM   #1
squiddyrules
LQ Newbie
 
Registered: Apr 2006
Posts: 1

Rep: Reputation: 0
linux problems


i have 2 problems ...and i can't resolve...pls hlp me!


1st to write a program that execute the command ls -a -l dirname where dirname is a parameter given at the program execution in command line or the current dir if the parameter is missing. At the end of execution the program need to write a message

and i need to use execlp() ...not system()

2nd master/slave program ...A C program :
-a process PO (master) who reads numebers from keybord and send in equal to 3 processes P1 P2 P3(slaves)....These calculate the sum(partial) and send back to P0...P0 calculate the whole sum and send the final result..
 
Old 04-05-2006, 07:30 AM   #2
amon
Member
 
Registered: May 2004
Location: UK
Distribution: Debian, Ubantu, CentOS
Posts: 146

Rep: Reputation: 17
The second question should have been asked seoperatly in linux programming.

for the first question:
Quote:
1st to write a program that execute the command ls -a -l dirname where dirname is a parameter given at the program execution in command line or the current dir if the parameter is missing. At the end of execution the program need to write a message
you can do this with a shell script. Unfortunatly you will have to learn some basics of shell scripting so look here: BASH Programming - Introduction HOW-TO

I'd imagin that your script you make will look something like this
Code:
#!/bin/sh
# ls script

# check ror a command line argument
if [ -z "$1" ]; then
        echo usage: $0 directory
        exit;
fi

#output the directory given to the script
echo dir: $1

#check that the directory exists
if [ ! -r $1 ]; then #if given directory doesn't exist
        echo Directory: $1 not found
        exit;
fi

# run the ls command
ls -a -l $1
Note this script will not fulfill your criteria but it is an example that will get you started
 
Old 04-05-2006, 07:58 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Homework assignment?
If you can supply more background, we may be more helpful. e.g. Are the 2 tasks related?
Two good references:
Bash Guide for Beginners--Machtelt Garrells--free at TLDP.org
Classic Shell Scripting--O'Reilly--any large bookstore--or O'Reilly.com
 
  


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
Debian Linux Woody and Red Hat Linux problems kissme1 Linux - Newbie 3 12-20-2005 07:39 PM
problems with windows programs in linux (QEMU, WINE, or linux alternative) bulldogzerofive Linux - Software 2 08-18-2005 06:49 PM
complet linux NewBie(problems with the downloaded copy of linux) merlin Linux - Software 3 03-25-2002 02:38 PM


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