home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / shell / 5316 < prev    next >
Encoding:
Text File  |  1993-01-08  |  2.0 KB  |  58 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!spsgate!mogate!newsgate!mario
  3. From: mario@wdc.sps.mot.com (Mario Nigrovic)
  4. Subject: Re: Problem with $*.
  5. Message-ID: <1993Jan8.194138.6825@newsgate.sps.mot.com>
  6. Sender: usenet@newsgate.sps.mot.com
  7. Nntp-Posting-Host: 223.199.55.4
  8. Organization: Motorola Western MCU Design Center
  9. References:  <1993Jan7.035540.3383@samba.oit.unc.edu>
  10. Date: Fri, 8 Jan 1993 19:41:38 GMT
  11. Lines: 45
  12.  
  13. In article <1993Jan7.035540.3383@samba.oit.unc.edu>, Shujaat.Ali@launchpad.unc.edu (Shujaat Ali) writes:
  14. |> 
  15. |> I am having this strange problem while using this line 
  16. |> 
  17. |> echo $* >> cfgargs      #where cfgargs is the filename
  18. |> 
  19. |> the input to the script is
  20. |> 
  21. |> $ cfg '9.1.1.1'
  22. |> 
  23. |> the output should give 9.1.1.1 in the cfgargs file.
  24. |> 
  25. |> The problem is that on execution one of the scripts provides the
  26. |> desired result, whereas the execution of second script places a blank
  27. |> line in the output file. Both the scripts are almost identical, in the
  28. |> past I have also experienced difficulty printing command line parameters
  29. |> like
  30. |> 
  31. |>     echo $1
  32. |> 
  33. |> The scripts are ran in ksh environment, any help is appreciated.
  34. |> 
  35. |>                     Thanks,
  36. |> 
  37. |>                     Shujaat.
  38. |> 
  39. |>            internet:  laUNChpad.unc.edu or 152.2.22.80
  40.  
  41. The question is: What shell are you using?  It is not impossible (rather, it's likely)
  42. that the variables $* have been toyed with by sh programs, which use "set" to help
  43. break up strings.  Also, most shells (all shells?) support "shift" which will discard
  44. command line args.  The best practice is to move the command line arguments into shell
  45. variables if you know you'll need them later on.
  46.  
  47. -- 
  48.  
  49.                             Mario
  50.  
  51. Mario Nigrovic <mario@wdc.sps.mot.com>        voice: (602) 821-4264
  52. Motorola Western MCU Design Center        fax:   (602) 821-4058
  53. *  -  -  -  -  -  -  -  -  -  -  -*-  -  -  -  -  -  -  -  -  -  -  *
  54. I don't have to take this abuse from you -- I've got hundreds of people
  55. waiting to abuse me.
  56.         --Bill Murray, "Ghostbusters"
  57. *  -  -  -  -  -  -  -  -  -  -  -*-  -  -  -  -  -  -  -  -  -  -  *
  58.