argv

C manipulate directories : how to position at a directory by giving its name in main arguments

吃可爱长大的小学妹 提交于 2019-12-11 19:42:50
问题 I'm having trouble to manipulate directories in C. I want to give the name of 2 directories as argument on main check if the first directory exists (in the current path) open the directory call a function (that i created) to create files and do stuff inside the directory close the directory and go into the 2nd directory and do the same . I wrote my code but it still not doing the stuffs inside the directories that i gave on main, instead it looks like i'm always positioned in the current

Terminology: Argv, Invoking a program

最后都变了- 提交于 2019-12-11 11:56:58
问题 Hy Python Community - This is a basic terminology question about Argv and "invoke" I'm new to python and programmring. I was reading about the argv function in the sys module on openbookproject.com: "The argv variable holds a list of strings read in from the command line when a Python script is run. These command line arguments can be used to pass information into a program at the same time it is invoked ." http://openbookproject.net/thinkcs/python/english2e/ch10.html It seems really clear

argparse - how pass to a method with kwargs or argv

本秂侑毒 提交于 2019-12-11 10:52:08
问题 I've been looking for a way to use **kwargs or *argv with argparse . I will from hard code to a dynamic way. Here is my hard code and a example how I will use it. def get_parser(): parser = argparse.ArgumentParser() parser.add_argument("-r", "--range", dest="r", nargs=8, help="AddRange Parameters") parser.add_argument("-p", "--parameters", dest="p", nargs=8, help="SetDefaults as Parameters") parser.add_argument("-r", "--range", dest="r", nargs=8, help="AddRange Parameters") return parser ""

Using execv (C language) to run commands from a linux command prompt

谁说我不能喝 提交于 2019-12-11 09:37:29
问题 The only part I am confused on thus far is how to set up execv with the first parameter as the current working directory. I've tried both "." and "~", neither are executing anything to the screen; same for "/." and "/~". I'm confused on how to have execv run something like this: $ ./prog ls -t -al And have it execute the commands after the program execution (which are stored into argv) in the current directory, or the same directory as the file is in (which will vary based on who is using it.

Using exec() in PHP: Passing arguments

夙愿已清 提交于 2019-12-11 07:25:36
问题 For testing purposes, let's say input.PHP looks like this <?php { $TO = "joe@net.net"; $FROM = "bob@net.net"; $SUB = "Yadda"; $BODY = "This is a test"; exec("/usr/bin/php /xxx.yyy.net/TESTS/sendit.PHP $TO $SUB $BODY $FROM > /dev/null &"); echo "DONE"; } ?> And the sendit.PHP which is called by exec() looks like this <?php $to = $argv[1]; $subject = $argv[2]; $message = $argv[3]; $headers = 'From: '.$argv[4]. "\r\n" . 'Reply-To: '.$argv[4]. "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to,

Understanding the dereference, address-of, and array subscript operators in C

我的未来我决定 提交于 2019-12-11 05:38:56
问题 I have argv[] defined as a char *. Using the following printf statements: printf("%s\n",argv[1]); // prints out the entire string printf("%p\n",&argv[1]); // & -> gets the address printf("%c\n",argv[1][0]);// prints out the first char of second var printf("%c\n",*argv[1]); // It's this last one I don't understand. What does it mean to print *argv[1] ? why isn't that the same as *argv[1][0] and how come you can't print out printf("%s\n",*argv[1]); . Also, why is &*argv[1] a different address

Access command line arguments as bytes in python3 [duplicate]

爷,独闯天下 提交于 2019-12-11 02:58:20
问题 This question already has answers here : sys.argv as bytes in Python 3k (2 answers) Closed last year . Is it possible to access the raw argv elements binary content ? $ python3 -c'import sys;print(sys.argv);' `echo -ne "\xff\x80\x00\xff"` ['-c', '\udcff\udc80\udcff'] 回答1: You can obtain the argv contant as bytes as follows: #!/usr/bin/python3 import sys arg1_bytes = sys.argv[1].encode(sys.getfilesystemencoding(), 'surrogateescape') Source: PEP 383 - Non-decodable Bytes in System Character

OpenCV argc and argv confusion

人走茶凉 提交于 2019-12-11 01:37:20
问题 I'm checking some OpenCV tutorial and found this line at the beginning (here is the link, code is under the CalcHist section http://opencv.willowgarage.com/documentation/c/histograms.html) if (argc == 2 && (src = cvLoadImage(argv[1], 1)) != 0) I've never seen this before and really don't understand it. I checked some Q&A regarding this subject but still don't understand it. Could someone explain to me what is the meaning of this line? Thanks! 回答1: The line does the following, in order: Tests

Help comparing an argv string

China☆狼群 提交于 2019-12-10 23:40:35
问题 I have: int main(int argc, char **argv) { if (argc != 2) { printf("Mode of Use: ./copy ex1\n"); return -1; } formatDisk(argv); } void formatDisk(char **argv) { if (argv[1].equals("ex1")) { printf("I will format now \n"); } } How can I check if argv is equal to "ex1" in C? Is there already a function for that? Thanks 回答1: #include <string.h> if(!strcmp(argv[1], "ex1")) { ... } 回答2: Just to give and example of using strings and dynamically allocating new strings. Probably useful when you don't

How to append a value to the array of command line arguments?

丶灬走出姿态 提交于 2019-12-10 20:26:22
问题 My application has entry point int main(int argc, char *argv[]) { } I need to extend *argv array to n+1 and append a value. For example, I need to append "-app_ver" . I'm a newcomer in C++ (with Java background). I know that I can't change array size, so I need any solution (any approach copying array, etc.) 回答1: Like cbuchart says, you have to create a new array or maybe a vector. Using vector and string object can be more simple than char* and array. Exemple : #include <vector> #include