Presentation Unix
Presentation Unix
The goal of the Weather Fetcher project is to create a tool that allows users to retrieve real-
time weather information for any city. The tool should fetch weather data from the
OpenWeatherMap API and display it in a user-friendly format. The project provides two
methods for fetching the data: one using a shell script and the other using system calls in
C. The user should be able to choose between these two methods to view weather details
such as temperature, humidity, wind speed, and weather description for the selected city.
The project aims to demonstrate the integration of external APIs with both scripting and
system-level programming techniques.
PROPOSED SOLUTION
The Weather Fetcher project will be implemented by integrating the OpenWeatherMap
API to retrieve real-time weather data for any given city. The solution will consist of
two parts: one using shell scripting and the other using system calls in C.
1. Shell Script:
• A shell script will be written to execute the curl command to fetch the weather data
from the OpenWeatherMap API.
• The output will be processed and formatted using the jq tool, which parses the JSON
response to display the weather information in a readable format.
• The script will prompt the user to enter a city name, fetch the weather data, and
display the results, including temperature, humidity, wind speed, and weather
description.
2.System Calls in C Method:
• A C program will be created that uses system calls to execute the same curl command
from within the C code.
• The program will open a pipe using the popen function to execute the command and read
its output.
• The output will be processed using the fgets function, and the weather information will
be displayed to the user.
Both methods will allow the user to view the weather data by simply entering a city name.
The solution will provide flexibility, showing how weather data can be retrieved using both
a higher-level shell scripting approach and a lower-level system programming approach.
Flow Chart
1. Start the Program
2.Display Main Menu
3. User Chooses an Option
4. Option 1 - Shell Script
5. Option 2 - System Calls
6.Option 3-Exit
6. Handle Invalid Choices
METHODS
• Command Execution: Executes the curl command with popen() to fetch the API response.
• Output Reading: Reads the response line by line using fgets() and displays it.
3. Menu Display:
• Method: Uses printf() to display a menu to the user and scanf() to capture the user's
choice.
• Purpose: Provides an interactive interface for the user to select between fetching weather
data via the shell script or system calls.
4.String Manipulation:
• Method: Uses snprintf() to safely construct the API call command string.
• Purpose: Avoids buffer overflows by limiting the size of the constructed string.
RESULTS:
Conclusion
In conclusion, the weather dashboard program demonstrates a practical and efficient way
to fetch and display real-time weather information using both shell scripting and system
calls in C. By integrating external tools like `curl` and `jq`, it effectively processes and
presents data from the OpenWeatherMap API in a user-friendly format. The program
highlights essential programming concepts such as menu-driven interaction, string
manipulation, command execution, and error handling. This project serves as an excellent
example of leveraging both scripting and programming approaches to achieve a seamless
and interactive user experience.
Thank
you