• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

asterisk in command line parameter converted to something else

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing a program to take 3 command line parameters and perform simple arithmetic. The second parameter is either +, -, *, /, or %. They all work fine except for the asterisk. So if my command line parameters are 6 * 5, when I display all the arguments, it says I have 4 arguments:
args[0]: 6
args[1]: Calculator.class
args[2]: MathWorker.class
args[3]: 5

I am using those two classes... how can i tell my program to just accept an asterisk as an asterisk without it being converted into a list of the classes I'm using? Thanks.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your shell automatically expands * to be a list of files in the current directory. How you do that depends on what shell you are using. Since you didn't know this I will guess that it is the Windows command prompt. Try typing these two lines at the command line:

dir *
dir '*'

and you will see what I mean.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use double quotations around the asterix
 
Eric Daly
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I am using the Windows XP command prompt. So there is not a way to disable the automatic "globbing" (I heard it referred to) that the command prompt promptly commands itself to do? Thanks for the help.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic