SlideShare a Scribd company logo
1 of 14
Lab 4: Introduction to
Scripting
Source Code Available on Github
 All the code that is written in this lab is available on
my github:
 https://github.com/petrauskasm/After-Hours-
Command-Line-Basics
What is scripting?
 Scripting is a program that automates the execution
of tasks
 Examples:
– creating 100 directories
– connecting to a server
 Scripting Languages:
– Python
– Ruby
– Perl
Command Line Arguments
 Most of the scripts that you will write will need
some optional input from the user
 These are called command line arguments
 Examples:
 ./fibonacci 50
 ./client -p 29773 cbw.sh
 ./av-detect signatures.av malware_directory
Fibonacci Script in C
 Goal: create a script in C that will calculate the nth
fibonacci number, where n is number you give to
the program
Main Function in C
 We will be focusing on the code in the main
function argc is a variable that hold the
number of arguments passed to
the program
argv is a list of the
argument
Converting the string to an integer
Letting the fib function do all the math
Compiling the C program
 C is a compiled language, so we can't just run the
code directly
 You can compile it two ways
 gcc -o fibonacci fibonacci.c
 Makefile
 A Makefile allows you to run the make command
to compile the program instead of typing out gcc …
over and over again
Contents of the Makefile
 The following is the contents of the makefile for the
fibonacci program:
 Typing make fibonacci or make in the terminal
will run gcc -o fibonacci fibonacci.c
 Typing make clean will remove the the compiled
program when you are done using it
 It must be named Makefile
Scripting in Python
 Scripting in Python or other scripting languages
does not require for the code to be compiled
 You just need the code and a couple other things
 Shebang statement
 main function
Shebang
 Scripting languages require a shebang statement
at the beginning of the file
 This tells the system which language to interpret
the rest of the file as
 Usually in the form #! interpreter
Shebang for python
The main function
 For a python script to run properly, a main function
needs to be specified
The main function
Command Line Arguments in
Python
 There are a couple of libraries that you can import
to parse command line arguments
 sys
 argparse
 Sys is a basic library that will uses a similar
method to the C programming language
 Argparse has more options for interpreting
command line arguments
Bash Scripting
 All of the commands you have been entering on
the command line are part of the Bash
programming language
 Examples:
 echo
 ls
 pwd
 You can write a script to execute these commands
Bash Scripting Example
 The following is a simple script written in bash
Shebang for bash
Some random bash commands

More Related Content

Similar to lab4.ppt

INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfSubramanyambharathis
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge imtiazalijoono
 
Computer programming tools and building process
Computer programming tools and building processComputer programming tools and building process
Computer programming tools and building processArghodeepPaul
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfDrIsikoIsaac
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionalsphanleson
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonRanjith kumar
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Shivang Bajaniya
 
00 C hello world.pptx
00 C hello world.pptx00 C hello world.pptx
00 C hello world.pptxCarla227537
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeksAashutoshChhedavi
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxManohar k
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Shipra Swati
 

Similar to lab4.ppt (20)

C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
C intro
C introC intro
C intro
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge
 
INTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptxINTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptx
 
Computer programming tools and building process
Computer programming tools and building processComputer programming tools and building process
Computer programming tools and building process
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)
 
00 C hello world.pptx
00 C hello world.pptx00 C hello world.pptx
00 C hello world.pptx
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Chapter1.pdf
Chapter1.pdfChapter1.pdf
Chapter1.pdf
 

Recently uploaded

costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Recently uploaded (20)

costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 

lab4.ppt

  • 1. Lab 4: Introduction to Scripting
  • 2. Source Code Available on Github  All the code that is written in this lab is available on my github:  https://github.com/petrauskasm/After-Hours- Command-Line-Basics
  • 3. What is scripting?  Scripting is a program that automates the execution of tasks  Examples: – creating 100 directories – connecting to a server  Scripting Languages: – Python – Ruby – Perl
  • 4. Command Line Arguments  Most of the scripts that you will write will need some optional input from the user  These are called command line arguments  Examples:  ./fibonacci 50  ./client -p 29773 cbw.sh  ./av-detect signatures.av malware_directory
  • 5. Fibonacci Script in C  Goal: create a script in C that will calculate the nth fibonacci number, where n is number you give to the program
  • 6. Main Function in C  We will be focusing on the code in the main function argc is a variable that hold the number of arguments passed to the program argv is a list of the argument Converting the string to an integer Letting the fib function do all the math
  • 7. Compiling the C program  C is a compiled language, so we can't just run the code directly  You can compile it two ways  gcc -o fibonacci fibonacci.c  Makefile  A Makefile allows you to run the make command to compile the program instead of typing out gcc … over and over again
  • 8. Contents of the Makefile  The following is the contents of the makefile for the fibonacci program:  Typing make fibonacci or make in the terminal will run gcc -o fibonacci fibonacci.c  Typing make clean will remove the the compiled program when you are done using it  It must be named Makefile
  • 9. Scripting in Python  Scripting in Python or other scripting languages does not require for the code to be compiled  You just need the code and a couple other things  Shebang statement  main function
  • 10. Shebang  Scripting languages require a shebang statement at the beginning of the file  This tells the system which language to interpret the rest of the file as  Usually in the form #! interpreter Shebang for python
  • 11. The main function  For a python script to run properly, a main function needs to be specified The main function
  • 12. Command Line Arguments in Python  There are a couple of libraries that you can import to parse command line arguments  sys  argparse  Sys is a basic library that will uses a similar method to the C programming language  Argparse has more options for interpreting command line arguments
  • 13. Bash Scripting  All of the commands you have been entering on the command line are part of the Bash programming language  Examples:  echo  ls  pwd  You can write a script to execute these commands
  • 14. Bash Scripting Example  The following is a simple script written in bash Shebang for bash Some random bash commands