TP Linux 3
TP Linux 3
TP 3 : Scripting introduction
Shell scripting is a text file with a list of commands that instruct an operating system to perform
certain tasks. A shell is an interface that interprets, processes, and executes these commands from the
shell script. It can be particularly helpful to automate repetitive tasks, helping to save time and reduce
human error.
What is shell scripting used for?
Shell scripting is primarily used to automate repetitive system tasks, such as backing up files,
monitoring system resources, and managing user accounts. By turning a series of commands into a
script, system administrators can save time, increase accuracy, and simplify complex tasks.
Basic shell scripting terms
Before we delve further into shell scripting, knowing a few definitions may come in handy when
exploring this topic:
• Shell: This program interprets shell scripting commands from the terminal and runs on
the server. This is the command-line user interface you choose and includes shells such
as the Bourne shell, Korn shell, Bourne-Again shell, and C shell.
When you create a shell script, you might use text editors like Nano or Vim and save the file with
a “.sh” extension. A shell interpreter interprets and executes these scripts; you can run them
from the command line whenever necessary.
One of interesting applications to use script shell is robotic application. Creating shell scripts for
robotic applications is to automate and streamline various processes involved in controlling,
managing, and monitoring robots. Shell scripts are powerful tools for automating tasks in the
Linux/Unix environment, which is commonly used in robotics due to its flexibility and open-
source nature. Shell scripts in robotic applications serve to improve efficiency, reliability, and
scalability by automating tasks, simplifying the management of complex systems, and providing
a robust interface for interacting with robots. They can also reduce the likelihood of human error,
facilitate easier debugging, and make system maintenance more efficient. For developers and
engineers working with robotics, shell scripting is a foundational skill that supports the
deployment, testing, and continuous operation of robots in real-world environments.
Page 1 sur 6
ENISO AU : 2024-2025
Here are some of the primary reasons and benefits for using shell scripts in robotic
applications:
• Routine Operations: Robots often perform tasks that need to be repeated, like starting,
stopping, or resetting software, moving parts, or logging data. A shell script can
automate these repetitive tasks, making the robot easier to control and manage.
• Sequence of Commands: Robotic systems often involve a series of complex steps (e.g.,
calibrating sensors, starting the motor, activating communication protocols, etc.), which
can be easily scripted to run automatically in the correct sequence.
• Initial Setup: When deploying a robotic system, there may be several configuration
steps (setting up ROS nodes, network configurations, environment variables). A shell
script can set up these parameters automatically, ensuring consistency and reducing
human error.
• System Initialization: It can launch the required processes, services, and background
tasks (like robot control software, vision systems, and sensor data processing) in a
specific order with one command.
• Communication with Hardware: Many robotic systems integrate with other software
tools or middleware platforms (e.g., ROS, OpenCV, TensorFlow). A shell script can be
used to initiate and manage these connections and ensure that all necessary
dependencies are in place.
• Interfacing with External Systems: Shell scripts can also facilitate communication
between the robot and other systems (like cloud servers or other robots) via network
protocols (HTTP, MQTT, etc.).
• Health Monitoring: Shell scripts can check the status of the robot's components (e.g.,
motors, sensors, or network connections), and if any component fails or malfunctions,
the script can send alerts or trigger troubleshooting actions.
• Error Detection: If a robot encounters an issue, a shell script can be used to check for
common error states (e.g., low battery, disconnected sensor) and attempt corrective
actions or log error messages.
• Debugging and Recovery: Shell scripts can automatically restart certain subsystems,
reset parameters, or provide logs to help developers debug issues in real-time.
Page 2 sur 6
ENISO AU : 2024-2025
• Task Scheduling: Robotic tasks may need to be performed at specific times or intervals.
Shell scripts can automate this scheduling, for example, using cron or other scheduling
utilities.
• Remote Operation: Shell scripts can facilitate remote control by executing commands
on a robot via SSH or other remote interfaces, enabling operators to manage the robot
from anywhere.
7. Simplified Interaction:
• Prototyping and Testing: When developing new robotic applications, shell scripts can
be used to quickly test different configurations, algorithms, or parameters without
requiring the full user interface or manual intervention.
• Low Overhead: Shell scripts are lightweight, easy to write, and have minimal
performance overhead, making them ideal for small and resource-constrained systems
that cannot afford the complexity of a full-fledged GUI-based interface.
• Sensor Data Processing: Shell scripts can help process data from various sensors and
use it to make real-time decisions. For example, a script might fetch data from a depth
sensor, process it, and trigger specific movement commands based on the input.
Page 3 sur 6
ENISO AU : 2024-2025
Introduction to vi :
Page 4 sur 6
ENISO AU : 2024-2025
Page 5 sur 6
ENISO AU : 2024-2025
"babelfish”)
Echo "dit it fall out your ear"
;;
*)
echo "you discovered unknown animal name
it"
;;
esac
./help.sh
Page 6 sur 6