This repository is a comprehensive collection of shell scripting projects, ranging from beginner to advanced levels. Each project is designed to demonstrate various aspects of shell scripting, including file management, process automation, system monitoring, and cloud resource management using AWS services.
/cpp-shell-scripting-project/
: Contains a shell script project that demonstrates creating, compiling, and executing C++ files using shell scripting./AWS-Shell-Scripting-Project/
: Contains a shell script for tracking and reporting usage of various AWS services within your AWS account./advanced-projects/
: (Coming Soon) Will contain more complex and advanced shell scripting projects covering a wide range of use cases.
This project automates the process of creating, writing, compiling, and executing simple C++ programs using a shell script. It demonstrates fundamental concepts of file manipulation, compilation, and execution automation through shell commands.
name.cpp
: A C++ program that prints"Ayush Poudel"
.country.cpp
: A C++ program that prints"Nepal"
.first_shell_script.sh
: A shell script that automates the creation, compilation, and execution of the above C++ files.print_name
: Compiled executable forname.cpp
.print_country
: Compiled executable forcountry.cpp
.
-
Creating C++ Files: The shell script uses the
touch
command to create two C++ source files:name.cpp
andcountry.cpp
. -
Writing C++ Code: It utilizes
echo
commands to write simple C++ code into the respective files, each designed to print a specific string to the console. -
Compiling the Files: The script compiles the C++ source files using
g++
, producing executable binaries namedprint_name
andprint_country
. -
Executing the Binaries: Finally, the script runs the executables, which output the predefined strings to the console.
- GCC Compiler: Ensure you have
g++
installed on your system. - Shell Environment: A Unix-like shell environment (e.g., Bash).
-
Clone the Repository:
git clone https://github.com/yourusername/Shell-Scripting-Projects-and-Documentation.git
-
Navigate to the Project Directory:
cd Shell-Scripting-Projects-and-Documentation/cpp-shell-scripting-project
-
Make the Shell Script Executable:
chmod +x first_shell_script.sh
-
Run the Script:
./first_shell_script.sh
-
Expected Output:
Ayush Poudel Nepal
This project provides a shell script to track and report the usage of various AWS services within your AWS account. It generates a consolidated report detailing the current state of resources such as S3 buckets, EC2 instances, Lambda functions, and IAM users.
- Name: Ayush Poudel
- Date: September 1, 2024
- Version: V1
aws_resource_tracker.sh
: The main script that retrieves and logs information about AWS resources.resource_tracker
: Output file generated by the script containing the detailed report.README.md
: Documentation and usage instructions for the AWS Usage Reporting Script.
-
S3 Buckets: Lists all S3 buckets in your AWS account and appends the information to the
resource_tracker
file. -
EC2 Instances: Retrieves all EC2 instance IDs using AWS CLI and formats the output using
jq
, appending the results to theresource_tracker
file. -
AWS Lambda Functions: Lists all Lambda functions available in your AWS account and appends the details to the
resource_tracker
file. -
IAM Users: Lists all IAM users and appends the information to the
resource_tracker
file. -
Debugging: The script uses
set -x
to enable debugging, printing each command to the terminal as it is executed for troubleshooting purposes.
-
AWS CLI: Installed and configured with necessary permissions.
- Installation: AWS CLI Installation Guide
-
jq: A command-line JSON processor.
- Installation Commands:
- macOS:
brew install jq
- Ubuntu/Debian:
sudo apt-get install jq
- CentOS/RHEL:
sudo yum install jq
- Windows:
choco install jq
- macOS:
- Installation Commands:
-
Clone the Repository:
git clone https://github.com/yourusername/Shell-Scripting-Projects-and-Documentation.git
-
Navigate to the AWS Project Directory:
cd Shell-Scripting-Projects-and-Documentation/AWS-Shell-Scripting-Project
-
Make the Script Executable:
chmod +x aws_resource_tracker.sh
-
Run the Script:
./aws_resource_tracker.sh
-
View the Report:
The script generates a file named
resource_tracker
in the current directory. View the report using:cat resource_tracker
aws s3 ls >> resource_tracker
- Lists all S3 buckets and appends the list to
resource_tracker
.
aws ec2 describe-instances | jq '.Reservations[].Instances[].InstanceId' >> resource_tracker
- Describes all EC2 instances and extracts their Instance IDs using
jq
, appending the results toresource_tracker
.
aws lambda list-functions | jq '.Functions[].FunctionName' >> resource_tracker
- Lists all Lambda functions and extracts their names, appending them to
resource_tracker
.
aws iam list-users | jq '.Users[].UserName' >> resource_tracker
- Lists all IAM users and extracts their usernames, appending them to
resource_tracker
.
-
The script uses debugging mode to trace command execution:
set -x
-
To disable debugging, comment out or remove the
set -x
line.
- AWS Credentials: Ensure your AWS CLI is configured with appropriate credentials and permissions.
- Output File Location: The
resource_tracker
file is created in the directory where the script is executed. - Error Handling: Currently, the script does not implement extensive error handling; ensure all commands execute successfully or modify the script to handle errors as needed.
- Error Handling: Implement comprehensive error checks and handling mechanisms.
- Email Notifications: Add functionality to automatically email the generated report to specified recipients.
- Additional Services: Extend the script to include monitoring of other AWS services such as RDS, DynamoDB, and CloudWatch metrics.
- Scheduling: Set up automated execution using cron jobs for periodic reporting.
- Logging: Implement detailed logging for auditing and troubleshooting purposes.
This repository will be continuously updated with more advanced shell scripting projects covering various domains and complexities. Upcoming projects may include:
- System Monitoring and Reporting: Scripts to monitor system performance, resource usage, and generate alerts.
- Backup and Recovery Automation: Automated solutions for backing up and restoring data across different environments.
- Network Operations and Security Scripts: Tools for managing network configurations, monitoring traffic, and enforcing security policies.
- DevOps Automation: Scripts to streamline CI/CD pipelines, infrastructure provisioning, and configuration management.
- Data Processing and Transformation: Advanced scripts for processing, transforming, and analyzing large datasets.
Contributions are welcome! If you have ideas for new projects, improvements, or bug fixes, please follow these steps:
-
Fork the Repository: Create a personal copy of the repository by clicking the "Fork" button.
-
Create a Feature Branch:
git checkout -b feature/your-feature-name
-
Make Changes: Implement your changes and ensure they are well-documented and tested.
-
Commit Changes:
git commit -m "Add your commit message here"
-
Push to Your Fork:
git push origin feature/your-feature-name
-
Submit a Pull Request: Open a pull request to merge your changes into the main repository.
For any questions, suggestions, or feedback, feel free to reach out:
- Email: ayush.poudel@example.com
- LinkedIn: Ayush Poudel
- GitHub: ayuspoudel
This repository is an ongoing project aimed at helping others learn and master shell scripting. Whether you're a beginner or an experienced scripter, you'll find useful resources and challenges to enhance your scripting skills.
---