You are not logged in.
Hello everyone. I am new here so sorry If I posted this to a wrong board ![]()
Arch Linux rocks and I have been using it for some time, long enough to try to improve it a bit and add my own software
)
I wanted to create some cool "commands" to use in Terminal or, without GUI, just while using the command interface.
The idea was simple, create a console application for Linux, and copy it to
/bin
it worked
The application I created in C++ using Code::Blocks was called "passgen"
and I want to use it like any other normal linux command that can be executed from Terminal.
for instance.
passgen -f ~~~example~ --use-numbers --use-signs --upper-case --screen-output
so, yes, I want my application to understand the arguments that were past to it from Terminal.
this command would actually tell my program to create a wordlist in the given format ( thanks to -f )
where all the ~ signs will be replaced with different signs. --use-numbers and --use-signs will tell the program
to allow numbers and signs, and --upper-case will tell the program to use upper case letters. And the --screen-output
will determinate will the information be printed to screen or written to a file in the directory user is currently in.
The program will then generate all the possible cases and print all of them seperated by new line.
i thought cin.getline() could do it. You know, to get the string and then extract the data I need, but it only works if I
typed this in Terminal:
passgen
-f ~~~exaple~ --use-numbers --use-signs --upper-case --screen-output
so.. do you know how can I get it to be all in one line only?
Thanks, and sorry for the novel ![]()
Last edited by TheDarkByte (2014-04-27 14:19:39)
---
TheDarkByte
Offline
Google "command line arguments cpp". (searching for documentation is the most useful skill you will learn as a programmer).
Last edited by Stebalien (2014-04-27 14:21:37)
Offline
Thanks! I found the solution!
---
TheDarkByte
Offline
It's also common to have a for loop:
int main(int argc, const char **argv) {
int i;
for (i = 1; i < argc; i++) {
/* do something with argv[i] */
}
return 0;
}While I prefer handling these bits manually like this (and I definitely think everyone should for a bit while learning) there is also the getopt library which is used in a large portion of FOSS software.
Please remember to edit your first post to prepend "[SOLVED]" to the title.
Last edited by Trilby (2014-04-27 14:44:34)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Moving to Programming and Scripting
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline