Sponsored Content
Full Discussion: problem with output.
Homework and Emergencies Homework & Coursework Questions problem with output. Post 302415947 by brooksie91 on Friday 23rd of April 2010 08:41:13 PM
Old 04-23-2010
problem with output.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

something is wrong with my output

2. Relevant commands, code, scripts, algorithms:

it has something to do with the expr command, i don't know what is wrong though.

3. The attempts at a solution (include all code and scripts):

Code:
#!/bin/sh

#James Brooks
#COP3353 - Assignment 4
#4/23/10

file=$1
directories=0
files=0
rfiles=0
xfiles=0
wfiles=0

if [ $# -ne  1 ]
   then
        echo "Usage: assignment4.sh <directory_name>"
exit
fi


if [ ! -d $file ]
then
        echo "$file: is not a directory"
exit
fi
        

for filename in $file/*
     do
        if [ -r $filename ];
            then 
             rfiles = `expr $rfiles + 1`   
        fi

        if [ -x $filename ]
           then
                xfiles = `expr $xfiles + 1`
        fi
 if [ -w $filename ] 
           then  
                wfiles = `expr $wfiles + 1`
        fi

        if [ -d $filename ]
           then
                directories = `expr $directories + 1`
        fi
        if [ -f $filename ] 
           then  
                files = `expr $files + 1`  
        fi
done
        
echo "Total number of directories: $directories"
echo "Total number of files: $files"
echo "Total number of readable items: $rfiles"
echo "Total number of writable items: $wfiles"
echo "Total number of executable items: $xfiles"

********************************************************
my output is just a whole bunch of this:

assignment4.sh: line 32: rfiles: command not found
assignment4.sh: line 37: xfiles: command not found
assignment4.sh: line 42: wfiles: command not found
assignment4.sh: line 47: directories: command not found
assignment4.sh: line 32: rfiles: command not found
assignment4.sh: line 37: xfiles: command not found
assignment4.sh: line 42: wfiles: command not found
assignment4.sh: line 52: files: command not found
assignment4.sh: line 32: rfiles: command not found
assignment4.sh: line 42: wfiles: command not found
assignment4.sh: line 52: files: command not found
assignment4.sh: line 32: rfiles: command not found
assignment4.sh: line 42: wfiles: command not found
assignment4.sh: line 52: files: command not found
assignment4.sh: line 32: rfiles: command not found
assignment4.sh: line 37: xfiles: command not found
assignment4.sh: line 42: wfiles: command not found
assignment4.sh: line 52: files: command not found
assignment4.sh: line 32: rfiles: command not found
assignment4.sh: line 42: wfiles: command not found
assignment4.sh: line 52: files: command not found


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Florida State, Myers, COP3353, Assignment 4

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by Scott; 04-23-2010 at 09:47 PM.. Reason: Added code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

problem with who -u output

I am using sco unix ver 5. who -u output lists the user name, tty,idle time and PID of the process. When I kill the idle process using kill -9 PID, the process is killed and the who -u output doesn't contain the user which is killed. This out of who -u is correct and desirable. But for past week, I... (0 Replies)
Discussion started by: V.V.KUMAR
0 Replies

2. UNIX for Dummies Questions & Answers

Output Problem

What do I have to do to get the startup and shutdown Info to display on my Graphical Monitor. As of right now, all i get is the log in screen for X windows on HP-UX. I want to see the boot process (3 Replies)
Discussion started by: Eric_Bakken
3 Replies

3. Shell Programming and Scripting

Problem in output

When i use the following command to get only the ip address from a file then i get a whole sentence and not only the ip address which i want. here is the script i am using: grep '^\{1,3\}\.\{1,3\}\.\{1,3\}\.\{1,3\}$' for example if this the file content: Many blogs provide commentary or... (2 Replies)
Discussion started by: snake450
2 Replies

4. Shell Programming and Scripting

output formatting problem

I would like to keep the complete lines in the output, but my script adds carriage returns for each space (e.g. keep BRITISH AIRWAYS on one line in the output): File1= BAW BRITISH AIRWAYS RYR RYAN AIR for i in $(cat File1) do echo $i done Output: BAW BRITISH AIRWAYS RYR... (4 Replies)
Discussion started by: barny
4 Replies

5. Programming

Problem with output

Hey guys, i am having problem with displaying my text. my text file is displayed in such a way and is called test....... Sam Worthington ... Jake SullyasZoe Saldana ... NeytiriasSigourney Weaver ... Dr. Grace AugustineasStephen Lang ... Colonel Miles QuaritchasJoel Moore ... Norm Spellman (as... (1 Reply)
Discussion started by: gregarion
1 Replies

6. Shell Programming and Scripting

output problem

#!/bin/gawk -f BEGIN{} {if ($0~/<a/ || $0~/<img/) link=link+1 } {if ($0~/<a/ || $0~/<img/) cnt++ } {if ($0~/<a/ && $0~/http/ ) weblink++ } {if ($0~/<img/) filelink++ } {if ($0~/<a/ && $0!~/http/) downloadlink++ } (8 Replies)
Discussion started by: pantelis
8 Replies

7. UNIX for Dummies Questions & Answers

Problem adjusting the output

Hi i m running a command watch -n 1 -d netstat -i to see the packet drops every 1 second. but the problem is the output is so long(Due to large number of virtual interfaces) it doesn't fit into the putty prompt. I dont need to monitor each and every network interface I m more interested in... (5 Replies)
Discussion started by: pinga123
5 Replies

8. UNIX for Dummies Questions & Answers

Grep output problem

Hi all, Here is my problem: I'm testing a login script for our mac Machines. This script output's in a csv file. The login script looks like this: echo "${computername}|${data1}|${data2}|${data3}" >> file.csv The csv file looks like this: Computername1|data1|data2|data3... (4 Replies)
Discussion started by: mattiasvdm
4 Replies

9. Shell Programming and Scripting

Problem getting the required output

I need a Korn shell script which does the folllowing:- If there is one "|" (pipe) delimited file so, the script should check the 5th field to be blank or not. if it is a blank tht entire line of the file should be redirected to another file. if the 5th field is not blank it should pass that. ... (4 Replies)
Discussion started by: Juhi Kashyap
4 Replies

10. Shell Programming and Scripting

Output formatting problem

Hello; I have a simple loop filtering a log: for LU in $(< LU-list-Final) do OUT=$(grep -B1 $LU cibc-src-ip.cap |egrep 'IP 16|IP 19|IP 15' |awk -F">" '{print $1}') if ; then echo " LU $LU was accessed by ===============> $OUT " echo "" fi done The current output snippet looks like... (2 Replies)
Discussion started by: delphys
2 Replies
Browser::Open(3)					User Contributed Perl Documentation					  Browser::Open(3)

NAME
Browser::Open - open a browser in a given URL VERSION
version 0.03 SYNOPSIS
use Browser::Open qw( open_browser ); ### Try commands specific to the current Operating System my $ok = open_browser($url); # ! defined($ok): no recognized command found # $ok == 0: command found and executed # $ok != 0: command found, error while executing ### Try all known commands my $ok = open_browser($url, 1); DESCRIPTION
The functions optionaly exported by this module allows you to open URLs in the user browser. A set of known commands per OS-name is tested for presence, and the first one found is executed. With an optional parameter, all known commands are checked. The "open_browser" uses the "system()" function to execute the command. If you want more control, you can get the command with the "open_browser_cmd" or "open_browser_cmd_all" functions and then use whatever method you want to execute it. API
All functions are not exported by default. You must ask for them explicitly. open_browser my $ok = open_browser($url, $all); Find an appropriate command and executes it with your $url. If $all is false, the default, only commands that match the current OS will be tested. If true, all known commands will be tested. If no command was found, returns "undef". If a command is found, returns the exit code of the execution attempt, 0 for success. See the "system()" for more information about this exit code. If no $url is given, an exception will be thrown: "Missing required parameter $url". open_browser_cmd my $cmd = open_browser_cmd(); Returns the best command found to open a URL on your system. If no command was found, returns "undef". open_browser_cmd_all my $cmd = open_browser_cmd_all(); Returns the first command found to open a URL. If no command was found, returns "undef". AUTHOR
Pedro Melo, "<melo at cpan.org>" COPYRIGHT &; LICENSE Copyright 2009 Pedro Melo. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2012-03-09 Browser::Open(3)
All times are GMT -4. The time now is 08:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy