Script program inputs in bash ubuntu linux [closed] - linux

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm in a course for C++ programming.
Our professor created a linux validation script against which our program output must match exactly.
It's running out of his own program and generates an output.txt file, then compares it against his output file, if it doesn't match it rejects the script.
The problem is, this program excepts probably 150-200 lines of input and if anything goes in wrong you have to start all over again. If you even enter an incorrect char, it must be restarted as the backspace registers as a character of its own.
How might I generate a bash script that would feed all of the input into the program automatically?
NOTE: We have to use his program as in: ~professor.name/submit asigname

You can create a text file:
answers.txt
answer1
answer2
...
answerN
and use that as stdin for the program:
./your_program < answers.txt

How might I generate a bash script that would feed all of the input into the program automatically?
Without any example code or input/output, it is hard to gauge what precisely is that you need.
Otherwise, for a generic tool to automate interactive console programs, I would suggest to take a look at the Expect.

Related

Using BASH FOR LOOP and PARALLEL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Just want to check if this is possible to automate in PRALLEL?. I have a bash script that reads a text file line per line and then takes the word of that line as a parameter then it will be processed by the bash script. For sample this would be the format of the text file
TEXT FILE
# cat test.txt
dog
cat
fish
rat
dove
Then line per line will be executed by a separate bash script via loop fashion like these
# for word in `cat test.txt`; do ./MY-BASH-SCRIPT.sh ${word}; done
Well this works fine however I it is executed one by one. May I ask for any suggestion on how can I possibly trigger the words in PRALLEL? I've gone and also read the GNU Parallel and gone some test however got no luck yet
this is now solved via parallel command:
cat test.txt | parallel ./MY-BASH-SCRIPT.sh {}

How to pass in '=' to a terminal command as is (Linux/macOS)? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am trying to run a program via its CLI. The command is something like this:
./Program -t -s -variables Param1=Value1,Param2="Value2=SubValue"
However, the Param2 is not accepted by the program. How can I pass in the "Value2=Subvalue" as is?
It depends on how the program is parsing the command line arguments. My guess is that the program is setting Param1 equal to Value1,Param2=Value2=SubValue. Try a space between Param1 and Param2. What program is this? What does the documentation say?
Without knowing which command it's a bit difficult to know how it expects its parameters, but generally they are not separated by commas. Try removing that and putting a space there instead.

What exactly is executable code? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I know about executable code, but I don't know what it exactly is.(for the system)
(I'm thinking about .sh or something else)
I tried to find something out with www.google.com but there was no result.
Can anyone explain it to me?
This is kind of a loose term but I would interpret this as a program that can be executed.
For example, if we have a Java file it is not directly executable...it's just a bunch text to the end user. You can't run the file directly like:
./foo.java # bad
Conversely, if you had a sh script that could be interpreted by your shell (and it has the proper permissions set, such as the executable bit) then it is executable. For example you could do:
./foo.sh # good
Another example would be code that has been compiled. If that foo.java file had been compiled into byte code then (assuming it had a main function) it could be executed directly (not the .java file, but the output of the build).
java foo # good
So, I think in this context, executable code means a file with code in it that can be executed directly by an end user.
To put it simply, "executable code" is any sequence of program instructions which is intended to be executed in some environment without prior translation. For example, a "binary executable" contains instructions which can be carried out by an appropriate microprocessor. An "executable shell script" contains instructions which are meant to be executed as-is by a shell program; from the shell's perspective, the script contains executable code, but from the processor's perspective it doesn't.

Correcting misspelled bash commands [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm looking for a way to correct bash commands if they have been misspelled.
Let's say you have installed a program called "FooBar" but you type "foobar" (or foo bar or FOOBAR or foebar) in your shell. Is there any way to check if something similar to what you are looking for exists in your PATH?
I'm thinking about writing a bash script that normalizes user input and uses the Levenshtein distance algorithm to check what they have typed against anything in PATH. But maybe there's already something is written out there or a better way to accomplish this task.
Any suggestions?
If you problem is case-sensitivity only, then you can switch this off in the readline configuration by the following:
echo "set completion-ignore-case On" >> ~/.inputrc
However, if you are seeking for some clever mechanism to execute similar commands (by using fuzzy logic for example) I'll not recommend to use such tool in a command-line since it could be very dangerous.
Imagine what could happen for example in commands like rmv? is it rm or mv? .. only the user can answer this question.
Note: This may be useful if you are running a Cygwin env where case-sensitivity is not a problem. In Linux commands are case sensitive. So switching this functionality off is not a good idea.

How commands are processed in LINUX [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to LINUX. This question sounds simple and stupid, but I suppose this has a lot of meaning behind it. "HOW COMMANDS ARE PROCESSED IN LINUX?". Which means suppose if I give ls command,what makes it to display list of all files inside the directory?. I have been searching for the answer, and I could not find any clear explanation for the same. Please help me to solve the same.
I'm new too. But I can answer this in a top level.(not too many details).
Everything in Linux is file, which means that the ls is also a file. You can type which ls
and you can see the file's location.
So, a command is a file, when you type and Enter, the system will search for the file in your PATH and execute it. When the file is executed, it will talk with the kernel and tell the kernel what resources it wants to use, and then the kernel will talk with the real hardware and let the computer do the work.
Some commands are shell keywords or shell builtins, so the shell (the program that accepts your commands) recognizes and processes them directly. Many other commands are executable programs found in the path; so, for example, if you enter ls, an executable called ls is executed (usually found in /bin, many commands cann be found in /usr/bin/). A command could also be an alias for another command.
You can use type command to find out what kind a command is, e.g.
type ls.

Resources