Script Name: mega_mkdir.sh
Description
This script will make directories if they do not exist for a path.
This is the Mega.nz equivalent of mkdir -p for UNIX.
Parameters
Required: The Path to create if it does not exist on Mega.nz
Optional: The configuration file to use that contain the credentials for the Mega.nz account you want to access.
See Set up .megarc.
-h
Optional: Display Script help
-v
Optional: Display script version
Possible Codes returned from Script
Code |
Definition |
0 |
Normal Exit. No Errors Encountered. |
40 |
If no argument is give for parameter one, the path to check. |
41 |
If megamkdir had error creating directory |
42 |
If a file was found with the same name as part of the path |
102 |
megals not found. Megtools requires installing or properly configure MT_MEGA_LS option of .mega_scriptsrc to point to the megals location |
111 |
Optional argument -i was passed in but the config can not be found or we do not have read permissions |
115 |
megamkdir not found. Megtools requires installing |
Remarks
Never pass in the directory Root to mega_mkdir.sh as the frist part of the path.
For -p "/MyPath/myfile" is fine; however, "/Root/MyPath/myfile" will fail.
If -i is omitted then you must have .megarc set in the current users home directory.
The mega_dir_file_exist.sh does not have any logging or output to the terminal. Only the Exit code is set.
If the name of this file "mega_mkdir.sh" is change for any reason then it needs to be reflected in the configuration file. See Configuration File.
Example
Script example to create a folder if it does not exist exist on default Mega.nz account on the command line.
# /bin/bash /usr/local/bin/mega_mkdir.sh -p '/testdir/2018/bigtest/deep/deeper/bottom'; echo $?
or to check a non-default account
# /bin/bash /usr/local/bin/mega_mkdir.sh -p '/testdir/2018/bigtest/deep/deeper/bottom' -i ~/.megarc_other; echo $?
Related
mega_dir_file_exist.sh Latest Source.