argv Questions

5

Solved

I pass a character to my program and I want to store this character to variable. For example I run my program like this ./a.out s file. Now I want to save the argv[1] (its the s) to a variable (let...
Hashum asked 15/1, 2014 at 11:54

11

Solved

I have an std::string containing a command to be executed with execv, what is the best "C++" way to convert it to the "char *argv[]" that is required by the second parameter of execv()? To clarify...
Bolanger asked 2/10, 2009 at 21:10

8

Solved

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]){ int fir; //badly named loop variable char *input[] = calloc( strlen(argv), sizeof(c...
Anastomosis asked 6/9, 2013 at 3:47

11

Solved

In many C++ IDE's and compilers, when it generates the main function for you, it looks like this: int main(int argc, char *argv[]) When I code C++ without an IDE, just with a command line compil...
Sharpie asked 11/6, 2010 at 15:45

9

Solved

I'm doing ex13 from Learn Python The Hard Way I'm trying to pass: python ex13.py raw_input() raw_input() raw_input() my code is below: from sys import argv script, first, second, third = arg...
Curie asked 4/9, 2014 at 21:25

6

Solved

I'm making a small program in C that deals with a lot of command line arguments, so I decided to use getopt to sort them for me. However, I want two non-option arguments (source and destination fi...
Kavanagh asked 6/8, 2013 at 11:48

3

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")) {...
Suzy asked 29/4, 2009 at 19:2

7

Solved

I'm reading a section from C Primer Plus about command-line argument argv and I'm having difficulty understanding this sentence. It says that, The program stores the command line strings in m...
Meadows asked 23/8, 2016 at 8:16

1

Some of my Rails tests require parameters from command line. After Rails 6.1. ARGV has been (for whatever reason) cleared and not available in application. Is there an alternative way to get parame...
Interstratify asked 16/4, 2021 at 11:18

2

Starting out learning F#. Want to make a simple program that just tells me what it found in the command line args. I have: [<EntryPoint>] let main argv = printfn "%A" argv match argv with...
Vervain asked 1/3, 2017 at 21:11

1

int main(int argc, char **argv){ printf("argv: %s\n",argv); // does not work and prints random stuff printf("*argv: %s\n",*argv); // works and prints ".a.out" } I ...
Deepfreeze asked 19/12, 2021 at 11:52

8

Solved

In a C program I can write argv[0] and the new name shows up in a ps listing. How can I do this in bash?
Exodus asked 15/7, 2010 at 0:10

3

I have a binary I've been trying to fuzz with AFL, the only thing is AFL only fuzzes STDIN, and File inputs and this binary takes input through its arguments pass_read [input1] [input2]. I was wond...
Alvinaalvine asked 25/7, 2020 at 16:42

10

Solved

I'm attempting to write a function in bash that will access the scripts command line arguments, but they are replaced with the positional arguments to the function. Is there any way for the functio...
Infix asked 29/4, 2010 at 21:31

7

Solved

I have a very simple python script that should scan a text file, which contains lines formatted as id='value' and put them into a dict. the python module is called chval.py and the input file is in...
Tabu asked 25/6, 2009 at 23:11

11

Solved

I'm currently going through Learn Python The Hard Way. I think this example might be out dated so I wanted to get feedback here on it. I'm using Python 3.1 from sys import argv script, fir...
Prosser asked 21/1, 2011 at 23:53

5

Solved

I have a Python script that needs to process a large number of files. To get around Linux's relatively small limit on the number of arguments that can be passed to a command, I am using find -print...
Staffordshire asked 1/2, 2012 at 20:40

3

Solved

Is there a way to use argparse with any list of strings, instead of only with sys.argv? Here's my problem: I have a program which looks something like this: # This file is program1.py import argpar...
Terti asked 9/8, 2016 at 14:38

2

Solved

With C/C++, we can get argv[0]: printf("%s\n",argv[0]) In C#, args begins with argv[1]. Non of bellow API gives exactly argv[0], at least under Linux: AppDomain.CurrentDomain.FriendlyName: onl...
Gynecoid asked 1/5, 2019 at 3:21

2

Solved

Scenario is as follows: I need to implement a command line argument system that allows both -p <value> and -p (no value for -p given) Is there any way to achieve this using argparse, or...
Streetman asked 15/6, 2018 at 7:22

7

Solved

In what encoding are the elements of sys.argv, in Python? are they encoded with the sys.getdefaultencoding() encoding? sys.getdefaultencoding(): Return the name of the current default string enc...
Voiceful asked 25/10, 2010 at 7:23

3

When user specify a password in MySQL cli, aka -pXXXXXX, the password parameter is replaced to -p****** in argv array. So when someone check the process list with ps, they can't see the password. ...
Corticate asked 16/1, 2017 at 2:24

10

When executing a Java application the process name given to it is usually java.exe or javaw.exe. But how can I make it be called by the name of my application?
Batwing asked 19/5, 2009 at 13:40

2

Solved

I wonder can input parameters of main() be changed at runtime. In other words, should we protect the app from possible TOCTTOU attack when handling data in argv? Currently, I don't know any way to ...
Unexperienced asked 30/1, 2020 at 13:16

3

Solved

I have a program written by my professor that prints the working directory (pwd) by using execve(), but I don't understand the parameters. pid_t pid = fork(); if(pid <0) perror(NULL); else if...
Thalassa asked 25/11, 2019 at 21:28

© 2022 - 2024 — McMap. All rights reserved.