home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!spsgate!mogate!newsgate!mario
- From: mario@wdc.sps.mot.com (Mario Nigrovic)
- Subject: Re: Problem with $*.
- Message-ID: <1993Jan8.194138.6825@newsgate.sps.mot.com>
- Sender: usenet@newsgate.sps.mot.com
- Nntp-Posting-Host: 223.199.55.4
- Organization: Motorola Western MCU Design Center
- References: <1993Jan7.035540.3383@samba.oit.unc.edu>
- Date: Fri, 8 Jan 1993 19:41:38 GMT
- Lines: 45
-
- In article <1993Jan7.035540.3383@samba.oit.unc.edu>, Shujaat.Ali@launchpad.unc.edu (Shujaat Ali) writes:
- |>
- |> I am having this strange problem while using this line
- |>
- |> echo $* >> cfgargs #where cfgargs is the filename
- |>
- |> the input to the script is
- |>
- |> $ cfg '9.1.1.1'
- |>
- |> the output should give 9.1.1.1 in the cfgargs file.
- |>
- |> The problem is that on execution one of the scripts provides the
- |> desired result, whereas the execution of second script places a blank
- |> line in the output file. Both the scripts are almost identical, in the
- |> past I have also experienced difficulty printing command line parameters
- |> like
- |>
- |> echo $1
- |>
- |> The scripts are ran in ksh environment, any help is appreciated.
- |>
- |> Thanks,
- |>
- |> Shujaat.
- |>
- |> internet: laUNChpad.unc.edu or 152.2.22.80
-
- The question is: What shell are you using? It is not impossible (rather, it's likely)
- that the variables $* have been toyed with by sh programs, which use "set" to help
- break up strings. Also, most shells (all shells?) support "shift" which will discard
- command line args. The best practice is to move the command line arguments into shell
- variables if you know you'll need them later on.
-
- --
-
- Mario
-
- Mario Nigrovic <mario@wdc.sps.mot.com> voice: (602) 821-4264
- Motorola Western MCU Design Center fax: (602) 821-4058
- * - - - - - - - - - - -*- - - - - - - - - - - *
- I don't have to take this abuse from you -- I've got hundreds of people
- waiting to abuse me.
- --Bill Murray, "Ghostbusters"
- * - - - - - - - - - - -*- - - - - - - - - - - *
-