Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:13:40+00:00 2026-06-05T04:13:40+00:00

I wrote a program that simulate the bash command in Linux, in C. It

  • 0

I wrote a program that simulate the bash command in Linux, in C.
It works perfectly with inputs from the keyboard, meaning:

  • application > file: redirect stdout of app to file(write output to file)
  • application < file: redirect stdin of app from file (read input from file)
  • application >> file: redirect stdout of app to file (append output to file)
  • app1 | app2: redirect stdout of app1 to stdin of app2
  • app &: means that app should be executed in the background

All these work, when I enter the command from the keyboard, as mentioned above.

In order to complete my assignment, I need to add one more element, which is
redirection from a file. Meaning, if my program is called bashSimulator, then
if I do this:

bashSimulator < fileWithCommands

then my program needs to get all the commands from the fileWithCommands and execute them.

I have no idea how to do the redirection from a file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:13:41+00:00Added an answer on June 5, 2026 at 4:13 am

    You read the commands from stdin instead of from a batch file or interactively from the user. Use isatty(3) to figure out if this is the case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a program that downloads some files from some servers. Currently program works
I've wrote a program that gets from the user a number, and then gets
I wrote a program that runs fine, however packaging the file into a jar
I wrote a Python program that acts on a large input file to create
I wrote a program that worked perfectly until the market required me to add
I wrote a program that reads a file with buffer reader and stores data
I wrote a program that uses ForkExec in Go. command := /bin/su -c '/bin/ls
I'm surprised about big file ftruncate and fsync operations. I wrote a program that
I wrote a program that forks some processes with fork(). I want to kill
I wrote a program that accepts and outputs Hebrew (i.e. right-to-left) text. In lieu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.