0

Everytime I've a reporting task to do, I'll have to

  1. Create a folder
  2. Copy the same HTML/JS files in it
  3. Edit the files as per the task/requirement
  4. upload them to S3 or local directory

I want to automate these tasks by creating a commandline( may be any ) app that takes care of all the above tasks, when i call a command , it should perform the below tasks, like



COMMAND create template
creates a folder with all the required/pre-defined HTML/JS files


I'm not able to figure out how to achieve this ?.

For example :

when i run the below command it creates a bunch of files in the folder where it's being run .

django-admin startproject myproject

I want to achieve the same thing . should I use nodejs, Pytho or any other language? How should I do this ? totally no idea about how to go and all. I use Mac and few users are on windows.

Thanks,
My first question & Totally a newbie :)

2 Answers2

0

First choose a language. I'd recommend Python.

  1. Find out how to create a directory in python and get this to work first.
  2. Find out how to cd (change directory) from python to the 'newly' created directory.
  3. This will require some more programming,depending on what you want.
  4. Find out how to upload a file/directory to some location with python.

  5. Add everything together in one script and voila.

  6. For every step a google search most likely will help you out.

Goodluck!

NemoMeMeliorEst
  • 513
  • 4
  • 10
  • Thank you for the detailed answer. If I develop the scripts using Python, i'll have to make all the others to install Python too which i'm skeptical about. – Chittimallu Jan 22 '19 at 10:09
  • Python is cross platform so this shouldn't be a problem. ;) And the installation is easy enough :) – NemoMeMeliorEst Jan 23 '19 at 13:41
0

For this task it's better to use bash script.
You need to access parameters from command line. Manipulate them like this.
Copy boilerplate code (Copy the same HTML/JS files in it) to new folder. If there is a few files, simple cp command could be used, if more, use loop.
And then change boilerplate code in this new folder with passed data using regular expressions. Like this, this or this.
And then upload folder to s3 using AWS CLI. Like this.

So, here is steps and source files. Now it's up to you to get it together with your conditions.

Grynets
  • 2,477
  • 1
  • 17
  • 41