How To Use Command-Line Programs

For scripts to aid with computation or simulation in cellular automata.
Post Reply
User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

How To Use Command-Line Programs

Post by gameoflifemaniac » May 25th, 2020, 11:12 am

The program finishes before I put in anything

EDIT by dvgrn: split this topic to address the question about command-line programs.
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
blah
Posts: 311
Joined: April 9th, 2016, 7:22 pm

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by blah » May 25th, 2020, 11:27 am

gameoflifemaniac wrote:
May 25th, 2020, 11:12 am
The program finishes before I put in anything
Do you understand how to use command line arguments? The program does not take any user input after you begin running it.

If you're using an IDE I have no particular advice other than to instead execute the compiled program from a command line, following the instructions.
succ

User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by gameoflifemaniac » May 25th, 2020, 12:10 pm

blah wrote:
May 25th, 2020, 11:27 am
gameoflifemaniac wrote:
May 25th, 2020, 11:12 am
The program finishes before I put in anything
The program does not take any user input after you begin running it.
All it does is displays the help screen.
Ok, stupid question time. So how do I use it?
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by gameoflifemaniac » May 25th, 2020, 12:58 pm

blah wrote:
May 25th, 2020, 12:51 pm
gameoflifemaniac wrote:
May 25th, 2020, 12:10 pm
All it does is displays the help screen.
Ok, stupid question time. So how do I use it?
Navigate to the directory where the executable is stored and run it in a command line. That's assuming you know (1) how to run an executable from a command line, (2) where the executable is, (3) how to navigate there in a command line, and (4) how to open a command prompt in the first place.

I'm not going to try to explain how to do this on whatever system/setup you happen to be using. You should try to look these things up and figure it out yourself. Passing arguments to an executable from a command prompt is incredibly basic and, in my opinion, outside the scope of this thread.
Yes, I did compile it and run it, but it does pretty much nothing and I don't know why! What am I doing wrong? Do I have to put what I am looking for in the code itself or something?
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by dvgrn » May 25th, 2020, 1:11 pm

gameoflifemaniac wrote:
May 25th, 2020, 12:58 pm
Yes, I did compile it and run it, but it does pretty much nothing and I don't know why! What am I doing wrong? Do I have to put what I am looking for in the code itself or something?
No, you don't have to recompile the code for each search.

It would be difficult for anyone to tell what you're doing wrong when you don't say, except very very vaguely, what you're actually doing.

What exactly did you type in the command line to run the program?

Did you at some point type "epsrc help", and did instructions come back, and did you understand them?

User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by gameoflifemaniac » May 25th, 2020, 1:20 pm

dvgrn wrote:
May 25th, 2020, 1:11 pm
gameoflifemaniac wrote:
May 25th, 2020, 12:58 pm
Yes, I did compile it and run it, but it does pretty much nothing and I don't know why! What am I doing wrong? Do I have to put what I am looking for in the code itself or something?
What did you type in the command line to run the program?

Did you at some point type "epsrc help", and did instructions come back, and did you understand them?
I can't type anything in!
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by dvgrn » May 25th, 2020, 1:34 pm

gameoflifemaniac wrote:
May 25th, 2020, 1:20 pm
I can't type anything in!
This is a perfect example of a problem report that conveys no useful information. If you can't type anything in, the problem could be

1) you don't have a computer;
2) your computer doesn't have a keyboard attached;
3) there's a sheet of clear Plexiglass over the keyboard;
4) ... never mind.

When something is wrong, there are always lots and lots of things that you can't do, but talking about them is almost never helpful in diagnosing the issue. What is (usually) helpful is if you explain, in great detail, step by step, what you actually _did_, and what happened when you did it... not what didn't happen. Background information should include what operating system you're using and what compiler you did the compilation with.

It sounds as if you've managed to compile the program into an executable, but then you're trying to run it without using a command-line prompt. In which case, it would be better if you didn't ignore questions like blah's: "Do you understand how to use command line arguments?"

User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by gameoflifemaniac » May 25th, 2020, 1:37 pm

I really don't know. The process exits immediately after outputting the help screen and it doesn't seem to do anything else. I do not want to sound like an idiot. And I really felt like I did since you gave me advice about such basic things you would say to one that doesn't know how to use a computer. Please understand :(
Attachments
Zrzut ekranu (233).png
Zrzut ekranu (233).png (225.05 KiB) Viewed 3937 times
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by dvgrn » May 25th, 2020, 2:42 pm

gameoflifemaniac wrote:
May 25th, 2020, 1:37 pm
I'm terribly sorry for sounding like an idiot (I'm not joking!), but I really don't know. The process exits immediately after outputting the help screen and it doesn't seem to do anything else. Please understand :(
Let's move this out of the epsrc thread, since blah didn't seem to want this level of question there.

It would still be helpful if you could answer questions more clearly. I'm guessing "I really don't know" is an answer to the question ""Do you understand how to use command line arguments?". But you didn't quote the question before the answer, so possibly you're answering something else.

I also mentioned it would be nice to know your operating system, and what you used to compile the C code to get epsrc.exe. The screenshot clears some of that up -- you're on Windows, and you do indeed have an epsrc.exe, so that's good. That information really belonged in your very first post reporting your problem -- people will tend to get really impatient if it takes multiple posts to get you to explain even the most basic relevant information.

Okay, so you're using the graphical user interface in Windows to double-click on epsrc.exe to run it. That's wrong -- blah's instructions are "execute the compiled program from a command line, following the instructions". The Windows GUI is not a command line.

Here's where the information you haven't given would be really useful. If you compiled epsrc.exe with Cygwin, then you'd have to go to a Cygwin command prompt to run it. It looks like you didn't do that -- you'd get an error message instead of the Help text in the screenshot, which was

Code: Select all

epsrc: Exhaustive Period Search
blah 2020

A program that finds alternating 2-state cellular automata defined on the
range-1 moore neighbourhood in which a single state 1 cell surrounded by 0
returns to being a single cell in some location after some (even) number of
steps of the simulation. In this help, a rule and its 1-cell object are
referred to as if they are the same.

Usage:
 epsrc cha (RULE) [OPTIONS]
   Characterise. Display speed of RULE, and MAP mask of all transitions
   that occur in its evolution.
 epsrc enum (RULE1) (RULE2) [OPTIONS]
   Enumerate. Allow bits that are 1 in RULE1 to vary in RULE2. Characterise
   all rules within this sub-rulespace.
 epsrc ham (NUM) (RULE) [OPTIONS]
   Hamming distance. Characterise all alternating rules with hamming
   distance of NUM from RULE.
   (NUM is an integer between 1 and 510 inclusive.)
 epsrc help
   Display this help and exit.
A MAP rulestring can have its base64 component truncated; left out digits
are fillied in with 0s ('A's). For example, in "epsrc ham 2 MAP", "MAP"
expands to "MAP" with 86 As after it.

Items in parentheses are necessary. Items in square brackets are optional.

Options:
 -p (NUM) Maximum period; disregard rules whose populations do not go below
          2 in NUM generations. NUM should be an even integer above 0.
 -m (NUM) Minimum period. Do not show rules with periods above this integer.
When blah said "If you're using an IDE..." -- IDE is short for "Integrated Development Environment", something like Visual Studio. If you did something like that, then the following might work:

1) Go to your Start bar and type cmd. The best match should be the "Command prompt" app. Click on that.
2) Type in (in your case)

cd C:\users\frane\Documents\kurs programowania\ and press Enter.

3) Type in one of the example invocations of the program that blah suggested, e.g.,

epsrc ham 3 MAP -p 6
(you don't need the "./" before the command, because this is Windows.)

The program will start running and printing out MAP strings that produce single-cell spaceships, which you can have a look at in LifeViewer like this:

Code: Select all

x = 1, y = 1, rule = MAPgAAAAAAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
o!
To stop the program running, hit Ctrl+C -- yes, the same thing that means "Copy" everywhere in the Windows GUI. Pretty much everything is different in command-line environments.

Case in point: if you want to copy a MAP string out of the command-line window, you can (usually, depending on the command-line window!) select it with your mouse -- but to copy it you might have to hit Enter or hit Ctrl+Insert, or you might have to right-click and choose Copy. Ctrl+C won't work at all.

Once you get all this figured out, it would be great if you could write a tutorial about it for the LifeWiki Tutorials section. Something like this is obviously badly needed!

... This post is definitely long enough, but if you have more difficulties, please post them here -- with lots of step-by-step details about what you tried and what happened.

User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by gameoflifemaniac » May 25th, 2020, 3:03 pm

dvgrn wrote:
May 25th, 2020, 2:42 pm
gameoflifemaniac wrote:
May 25th, 2020, 1:37 pm
I'm terribly sorry for sounding like an idiot (I'm not joking!), but I really don't know. The process exits immediately after outputting the help screen and it doesn't seem to do anything else. Please understand :(
Let's move this out of the epsrc thread, since blah didn't seem to want this level of question there.

It would still be helpful if you could answer questions more clearly. I'm guessing "I really don't know" is an answer to the question ""Do you understand how to use command line arguments?". But you didn't quote the question before the answer, so possibly you're answering something else.

I also mentioned it would be nice to know your operating system, and what you used to compile the C code to get epsrc.exe. The screenshot clears some of that up -- you're on Windows, and you do indeed have an epsrc.exe, so that's good. That information really belonged in your very first post reporting your problem -- people will tend to get really impatient if it takes multiple posts to get you to explain even the most basic relevant information.

Okay, so you're using the graphical user interface in Windows to double-click on epsrc.exe to run it. That's wrong -- blah's instructions are "execute the compiled program from a command line, following the instructions". The Windows GUI is not a command line.

Here's where the information you haven't given would be really useful. If you compiled epsrc.exe with Cygwin, then you'd have to go to a Cygwin command prompt to run it. It looks like you didn't do that -- you'd get an error message instead of the Help text in the screenshot, which was

Code: Select all

epsrc: Exhaustive Period Search
blah 2020

A program that finds alternating 2-state cellular automata defined on the
range-1 moore neighbourhood in which a single state 1 cell surrounded by 0
returns to being a single cell in some location after some (even) number of
steps of the simulation. In this help, a rule and its 1-cell object are
referred to as if they are the same.

Usage:
 epsrc cha (RULE) [OPTIONS]
   Characterise. Display speed of RULE, and MAP mask of all transitions
   that occur in its evolution.
 epsrc enum (RULE1) (RULE2) [OPTIONS]
   Enumerate. Allow bits that are 1 in RULE1 to vary in RULE2. Characterise
   all rules within this sub-rulespace.
 epsrc ham (NUM) (RULE) [OPTIONS]
   Hamming distance. Characterise all alternating rules with hamming
   distance of NUM from RULE.
   (NUM is an integer between 1 and 510 inclusive.)
 epsrc help
   Display this help and exit.
A MAP rulestring can have its base64 component truncated; left out digits
are fillied in with 0s ('A's). For example, in "epsrc ham 2 MAP", "MAP"
expands to "MAP" with 86 As after it.

Items in parentheses are necessary. Items in square brackets are optional.

Options:
 -p (NUM) Maximum period; disregard rules whose populations do not go below
          2 in NUM generations. NUM should be an even integer above 0.
 -m (NUM) Minimum period. Do not show rules with periods above this integer.
When blah said "If you're using an IDE..." -- IDE is short for "Integrated Development Environment", something like Visual Studio. If you did something like that, then the following might work:

1) Go to your Start bar and type cmd. The best match should be the "Command prompt" app. Click on that.
2) Type in (in your case)

cd C:\users\frane\Documents\kurs programowania\ and press Enter.

3) Type in one of the example invocations of the program that blah suggested, e.g.,

epsrc ham 3 MAP -p 6
(you don't need the "./" before the command, because this is Windows.)

The program will start running and printing out MAP strings that produce single-cell spaceships, which you can have a look at in LifeViewer like this:

Code: Select all

x = 1, y = 1, rule = MAPgAAAAAAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
o!
To stop the program running, hit Ctrl+C -- yes, the same thing that means "Copy" everywhere in the Windows GUI. Pretty much everything is different in command-line environments.

Case in point: if you want to copy a MAP string out of the command-line window, you can (usually, depending on the command-line window!) select it with your mouse -- but to copy it you might have to hit Enter or hit Ctrl+Insert, or you might have to right-click and choose Copy. Ctrl+C won't work at all.

Once you get all this figured out, it would be great if you could write a tutorial about it for the LifeWiki Tutorials section. Something like this is obviously badly needed!

... This post is definitely long enough, but if you have more difficulties, please post them here -- with lots of step-by-step details about what you tried and what happened.
Oh sorry, but by "I really don't know" I meant "I really don't know what to do, what I am doing wrong" And I edited my previous reply so it sounds more appropriate. I'll look at your advice.
EDIT: Oh, yes, I don't really know what command lines are. I'll look at your advice.
EDIT 2: How silly of me! I knew I would have to use CMD and tried it, but when I typed the commands like epsrc ham 3 MAP -p 6, it didn't know what to do. Now I know that I have to first type in the location of the exe file and THEN the epsrc command. And I didn't really distinguish executing programs from executing command lines, which also confused me. Ultra mega sorry for this confusion! I was just so worried that you didn't understand my problem, but it was just my mistake!
EDIT 3: Ooh nice it works! Again ultra mega sorry for the confusion! But still thanks for helping!
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: epsrc: A program to find 1-cell spaceships in 2-state rules

Post by dvgrn » May 25th, 2020, 4:07 pm

gameoflifemaniac wrote:
May 25th, 2020, 3:03 pm
EDIT 3: Ooh nice it works! Again ultra mega sorry for the confusion! But still thanks for helping!
You're very welcome. Command-line programs work so differently from Windows-based programs, that it can be totally confusing when nothing works the way you expect it to.

That said, a Google search on "How to run command line programs" will take you straight to tutorials like this one, so there are definitely paths toward figuring this kind of thing out.

I hope it's okay if we leave this thread here, with this title. I'm hoping that a few other people might find it useful to have a thread like this.

I said a few things that were maybe slightly rude, like the part about all the different problems that would cause your symptom of "I can't type anything in" -- but it seemed like a really good example of a problem report that was just plain not specific enough to be useful.

More Stuff That Hasn't Been Mentioned Yet
Anyway, not to worry, anyone with a Windows background and no previous experience with command-line programs will have absolutely no idea where to start. And we've really only scratched the surface so far. There are all kinds of useful tricks, like

bringing in input from a file with "<",

and sending the output to a file with ">",

and piping the output of one command into the input of another with "|",

and doing a large number of tasks in a set sequence by writing a batch file and executing that,

and troubleshooting problems caused by the difference between Windows, Mac, and Linux newline characters,

and probably a bunch of other things I'm not thinking of. Each of these is worth investigating and trying out; if you spend much time running command-line utilities you'll eventually have a use for all of these.

User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: How To Use Command-Line Programs

Post by gameoflifemaniac » May 25th, 2020, 4:58 pm

All my confusion came from the fact I didn't know command line programs and normal executables were different things.
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: How To Use Command-Line Programs

Post by dvgrn » May 25th, 2020, 5:34 pm

gameoflifemaniac wrote:
May 25th, 2020, 4:58 pm
All my confusion came from the fact I didn't know command line programs and normal executables were different things.
They're not entirely distinct categories. Quite often you can pass in some command-line parameters to a "normal executable", and it will change its behavior. You're starting to find out a little bit about how normal executables in Windows really work, at a deeper level.

For example, if you look at a Windows shortcut file, extension .lnk, right-click and choose "Properties", you might well see some command-line parameters included in the "Target" field. Like, my Cygwin installation has the following target:

Code: Select all

C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -
No idea what that last dash is about, but the "-i /Cygwin-Terminal.ico" is standard syntax for passing startup parameters.

But for the kinds of search programs common in the CA world, the big difference is the way output data gets sent to STDOUT, "standard out" -- i.e., it shows up as text in the command-line window -- rather than to some kind of graphical user interface created by the executable. Command-line programs tend to deal with their text input and output via "streams" -- e.g., STDIN, STDOUT, STDERR. All of these are good terms to feed into Google and read up on until they're at least somewhat familiar.

Post Reply