Stuck on #AP6 Return a file

Hello,
Please help me out in understanding a few instructions for RETURN A FILE challenge:

  1. is the directory flag specified by the tester while executing the program as below, is to be read as cmd input ? Will some data be already written in file that has to be read?
$ ./your_program.sh --directory /tmp/
  1. for this request: echo -n 'Hello, World!' > /tmp/foo, it says that hello world to be written in foo stored in tmp directory. So, do we have to read some text from cmd line and write to the file?

I’m not sure what to imply after reading these instructions, so some help would be appreciated.

Thanks
Kunal

Hi

Yes, you’ll need to retrieve the command arguments, depending on the language you use the method will differ.

For instance in Go, I use the “os” module which allows me to access the “os.Args” which is an array containing the command line arguments, in your case this array would be:

os.Args: {“your_program.sh”, “–directory”, “/tmp/”}

A google search on how to retrieve command line arguments for your programing language should get you what you need.

You have to open the file, read its content, and include it in your response body per the instructions.

2 Likes

Thanks a lot for explaining it so clearly. It answers my questions.

2 Likes

A post was split to a new topic: Error in reading the data from the file as specified by --directory flag

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.