Sponsored Content
Homework and Emergencies Homework & Coursework Questions Shell Scripting with Arguments Post 302686509 by dw15 on Tuesday 14th of August 2012 06:19:42 PM
Old 08-14-2012
Shell Scripting with Arguments

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

Problem 1:

I need to create a shell script the takes three arguments and echo's out "There once was a ____that____who like to_____"
The arguments go where the blanks are.



Problemt 2:

-Do an LS and store the listings in a file

-Open the file in emacs.

-create a macro that converts that single line to the command "mv file.txt file.dat"

-run the macro over the entire file.

-chmod +x the listing file

-run the file as a script.





2. Relevant commands, code, scripts, algorithms:

For problem one my instructor provides me with this example:

echo -n "some argument"

echo $1

how I've been reading it is like a C++ code

cout << "Some argument"

cin >> argurment

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

For problem 1 I've tried it many different ways, this is my latest attempt:

echo -n "There once was a "
echo $1
echo -n "that "
echo $2
echo -n "who liked to "
echo $3
echo -n "There once was a " $1 " that " $2 " who liked to " $3

I believe my teacher wants the echo to be just on one line. I dont want the code given to me, I'm really just hoping someone can show me what I'm doing wrong so I can correctly do it. There is a part b to this question and if I understand what I'm doing wrong in part a im positive I can do part b.

For problem 2 I've run an ls and moved all .txt files to a new file called change. From there I created a macro that searched for all .txt and replaced them with .dat. I'm having a hard time understanding how to mv this data to replace the old .txt files in the directory I copied them from.

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

Portland Community College, Hillsboro, OR, United States, Mike Noel, CS 140u Intro to Unix

Link -PCC Class Schedule

Last edited by dw15; 08-14-2012 at 08:15 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Arguments to a shell program

Hi List, Is it possible to pass one argument to a shell program eg) there is a shell program abc which takes one arguments abc one Due to some reasons I pass abc one two Now one,two must be considered as "one" argument to the shell programs. Any suggestions,hints are welcome. ... (3 Replies)
Discussion started by: csvenkata
3 Replies

2. Shell Programming and Scripting

Shell script with arguments

Hi All, I need some help/ideas in coming up with a shell script. Basically, the script should install 1 or 2 or 3 packages based on the input arguments. For example, if I type in pkgscript.sh a1 a2 a3, it should install all the 3 scripts and pkgscript.sh a1 should install only a1. If a... (3 Replies)
Discussion started by: sankar6254
3 Replies

3. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

4. Shell Programming and Scripting

Bash Shell - # of arguments

Hi!, How can I check the number of arguments passed from the shell in a bash shell ? (1 Reply)
Discussion started by: DNAx86
1 Replies

5. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

6. Shell Programming and Scripting

Using arguments in Shell script

Hello, I have to make a shell script doing that : the program tests if there is an argument, if there is it checks whether this is a directory or not, If it is it opens it. for any .c file in the directory it prints 2 lines in the screen : the dependence line of the .o and compiler commend... (1 Reply)
Discussion started by: dekl
1 Replies

7. Shell Programming and Scripting

sub arguments to shell script

Hi, I have a shell script, when run it i get a prompt to enter arguments say 1 for doing my next task otherwise q for quit. What I am trying to do is run the shell script with the argument passed in however it does not seem to work. This is what I did ./test.sh 1 Instead it printed the line... (6 Replies)
Discussion started by: aqua9
6 Replies

8. Shell Programming and Scripting

Shell scripting with passing arguments

Hi All, I am using the script for creating local queue and passing the arguments while running the script as below n=0 while do e=`expr $n + 3` echo 'DEFINE QL('$e') MAXDEPTH('$6') MAXMSGL('$7') DEFPSIST('$8') '$9'' | /apps/mqm_opt/bin/runmqsc $2 n=`expr $n + 1` done Running the... (5 Replies)
Discussion started by: Anusha M
5 Replies

9. Shell Programming and Scripting

Scripting with arguments for ping command

This is the script I already have but I have problems with two arguments the first argument -t , I want to count 200 by the last digit of the IP address for example when I run the script ./ping.sh -t 17, the output would be192.168.0.217 is upThe second arguments --up won't work. Could anybody... (1 Reply)
Discussion started by: Roggy
1 Replies

10. UNIX for Beginners Questions & Answers

Beginner at bash scripting - need help with passing arguments

I at the moment, making a simple bash script, capable of setting up an workspace for me, so i don't have to do it manually.. Problem is though i can't seem to provide the bash script any argument, without running into my error checks, checking for input... Here is the code: #!/bin/bash... (7 Replies)
Discussion started by: kidi
7 Replies
CPANPLUS::Shell(3pm)					 Perl Programmers Reference Guide				      CPANPLUS::Shell(3pm)

NAME
CPANPLUS::Shell SYNOPSIS
use CPANPLUS::Shell; # load the shell indicated by your # config -- defaults to # CPANPLUS::Shell::Default use CPANPLUS::Shell qw[Classic] # load CPANPLUS::Shell::Classic; my $ui = CPANPLUS::Shell->new(); my $name = $ui->which; # Find out what shell you loaded $ui->shell; # run the ui shell DESCRIPTION
This module is the generic loading (and base class) for all "CPANPLUS" shells. Through this module you can load any installed "CPANPLUS" shell. Just about all the functionality is provided by the shell that you have loaded, and not by this class (which merely functions as a generic loading class), so please consult the documentation of your shell of choice. BUG REPORTS
Please report bugs or other issues to <bug-cpanplus@rt.cpan.org<gt>. AUTHOR
This module by Jos Boumans <kane@cpan.org>. COPYRIGHT
The CPAN++ interface (of which this module is a part of) is copyright (c) 2001 - 2007, Jos Boumans <kane@cpan.org>. All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. SEE ALSO
CPANPLUS::Shell::Default, CPANPLUS::Shell::Classic, cpanp perl v5.12.1 2010-04-26 CPANPLUS::Shell(3pm)
All times are GMT -4. The time now is 07:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy