SlideShare a Scribd company logo
1 of 13
UNIX and “C” For more info check out the Unix man pages (i.e., do “man -k topic-you-wish-to-search”)  -or- Unix in a Nutshell -and C Language Reference Manual (K&R). This document gives a starter in how to program in C.  There’s very little here that’s UNIX specific – all the functions described here will run on any operating system.
Remember printf? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What about Input? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What are stdin, stdout, stderr? ,[object Object],[object Object],[object Object]
File I/O Operations ,[object Object],[object Object],[object Object],[object Object],[object Object]
fopen ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
fclose #include<stdio.h> #include<errno.h> void main() { FILE *myfile; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fclose( myfile ); /* could check for error here, but usually not needed */ }
fscanf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fclose( myfile ); /* could check for error here, but usually not needed */ }
fprintf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fprintf( myfile, “%d %d %d %s, i, j, k, buffer ); fclose( myfile ); /* could check for error here, but usually not needed */ }
Pipes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
To send mail use “sendmail” ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Putting it all together with pipes #include<stdio.h> #include<errno.h> void main() { FILE *mailpipe; if( NULL == (mailpipe = popen( “usr/lib/sendmail -t”, “w”))) { perror(“popen failed in main”); exit(-1); } fprintf( mailpipe, “To: chrisc@cs.rpi.edu ” ); fprintf( mailpipe, “From: bogus ” ); fprintf( mailpipe, “Subject: test ” ); fprintf( mailpipe, “This is a test. ” ); fprintf( mailpipe, “.” ); pclose( mailpipe ); /* could check for error here, but usually not needed */ }
Other useful commands... ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scriptingCorrado Santoro
 
Shell Scripts
Shell ScriptsShell Scripts
Shell ScriptsDr.Ravi
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell ScriptingRaghu nath
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash scriptSimon Su
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell ScriptingJaibeer Malik
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsDr.Ravi
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaiCreateWorld
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell ScriptingRaghu nath
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scriptingAkshay Siwal
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filtersbhatvijetha
 

What's hot (20)

Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Chap06
Chap06Chap06
Chap06
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Unix shell scripts
Unix shell scriptsUnix shell scripts
Unix shell scripts
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 

Similar to Unix And C

Write a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docxWrite a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docxSUKHI5
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)Dmitry Zinoviev
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoChris McEniry
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionProf. Wim Van Criekinge
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-duttAnil Dutt
 
C_and_C++_notes.pdf
C_and_C++_notes.pdfC_and_C++_notes.pdf
C_and_C++_notes.pdfTigabu Yaya
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineMatt Provost
 
Hello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdfHello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdffashionfootwear1
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYRajeshkumar Reddy
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.pptSIDDHARTHANANDCSE202
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.pptyuvrajkeshri
 
C Under Linux
C Under LinuxC Under Linux
C Under Linuxmohan43u
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageRené Ribaud
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsAbhay Sapru
 

Similar to Unix And C (20)

Write a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docxWrite a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docx
 
Prog i
Prog iProg i
Prog i
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 
CInputOutput.ppt
CInputOutput.pptCInputOutput.ppt
CInputOutput.ppt
 
7.0 files and c input
7.0 files and c input7.0 files and c input
7.0 files and c input
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-dutt
 
C_and_C++_notes.pdf
C_and_C++_notes.pdfC_and_C++_notes.pdf
C_and_C++_notes.pdf
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command Line
 
Hello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdfHello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdf
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
 
Unit5
Unit5Unit5
Unit5
 
Python build your security tools.pdf
Python build your security tools.pdfPython build your security tools.pdf
Python build your security tools.pdf
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 

More from Dr.Ravi

Corporate Overview
Corporate  OverviewCorporate  Overview
Corporate OverviewDr.Ravi
 
Excel For The Ceo
Excel For The CeoExcel For The Ceo
Excel For The CeoDr.Ravi
 
Project Specs Pf
Project Specs PfProject Specs Pf
Project Specs PfDr.Ravi
 
Assignments Programming Fundamentals
Assignments Programming FundamentalsAssignments Programming Fundamentals
Assignments Programming FundamentalsDr.Ravi
 
Hdd Chssc
Hdd ChsscHdd Chssc
Hdd ChsscDr.Ravi
 
Chssc Day3
Chssc Day3Chssc Day3
Chssc Day3Dr.Ravi
 
Chssc Day1
Chssc Day1Chssc Day1
Chssc Day1Dr.Ravi
 
Chssc Assignments
Chssc AssignmentsChssc Assignments
Chssc AssignmentsDr.Ravi
 
Chssc Day4
Chssc Day4Chssc Day4
Chssc Day4Dr.Ravi
 
Chssc Day2
Chssc Day2Chssc Day2
Chssc Day2Dr.Ravi
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2Dr.Ravi
 
Unix Book
Unix BookUnix Book
Unix BookDr.Ravi
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04spDr.Ravi
 
Wicked Cool Shell Scripts
Wicked Cool Shell ScriptsWicked Cool Shell Scripts
Wicked Cool Shell ScriptsDr.Ravi
 
SAP INTRO
SAP INTROSAP INTRO
SAP INTRODr.Ravi
 

More from Dr.Ravi (18)

Corporate Overview
Corporate  OverviewCorporate  Overview
Corporate Overview
 
Excel For The Ceo
Excel For The CeoExcel For The Ceo
Excel For The Ceo
 
Project Specs Pf
Project Specs PfProject Specs Pf
Project Specs Pf
 
Pf Day5
Pf Day5Pf Day5
Pf Day5
 
Assignments Programming Fundamentals
Assignments Programming FundamentalsAssignments Programming Fundamentals
Assignments Programming Fundamentals
 
Hdd Chssc
Hdd ChsscHdd Chssc
Hdd Chssc
 
Chssc Day3
Chssc Day3Chssc Day3
Chssc Day3
 
Chssc Day1
Chssc Day1Chssc Day1
Chssc Day1
 
Pf Day3
Pf Day3Pf Day3
Pf Day3
 
Ldd Pf
Ldd PfLdd Pf
Ldd Pf
 
Chssc Assignments
Chssc AssignmentsChssc Assignments
Chssc Assignments
 
Chssc Day4
Chssc Day4Chssc Day4
Chssc Day4
 
Chssc Day2
Chssc Day2Chssc Day2
Chssc Day2
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2
 
Unix Book
Unix BookUnix Book
Unix Book
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
 
Wicked Cool Shell Scripts
Wicked Cool Shell ScriptsWicked Cool Shell Scripts
Wicked Cool Shell Scripts
 
SAP INTRO
SAP INTROSAP INTRO
SAP INTRO
 

Recently uploaded

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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Recently uploaded (20)

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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Unix And C

  • 1. UNIX and “C” For more info check out the Unix man pages (i.e., do “man -k topic-you-wish-to-search”) -or- Unix in a Nutshell -and C Language Reference Manual (K&R). This document gives a starter in how to program in C. There’s very little here that’s UNIX specific – all the functions described here will run on any operating system.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. fclose #include<stdio.h> #include<errno.h> void main() { FILE *myfile; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fclose( myfile ); /* could check for error here, but usually not needed */ }
  • 8. fscanf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fclose( myfile ); /* could check for error here, but usually not needed */ }
  • 9. fprintf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fprintf( myfile, “%d %d %d %s, i, j, k, buffer ); fclose( myfile ); /* could check for error here, but usually not needed */ }
  • 10.
  • 11.
  • 12. Putting it all together with pipes #include<stdio.h> #include<errno.h> void main() { FILE *mailpipe; if( NULL == (mailpipe = popen( “usr/lib/sendmail -t”, “w”))) { perror(“popen failed in main”); exit(-1); } fprintf( mailpipe, “To: chrisc@cs.rpi.edu ” ); fprintf( mailpipe, “From: bogus ” ); fprintf( mailpipe, “Subject: test ” ); fprintf( mailpipe, “This is a test. ” ); fprintf( mailpipe, “.” ); pclose( mailpipe ); /* could check for error here, but usually not needed */ }
  • 13.