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 7042835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:12:58+00:00 2026-05-28T02:12:58+00:00

I want to run something like cat file.tar | base64 | myprogram -c |

  • 0

I want to run something like

cat file.tar | base64 | myprogram -c "| base64 -d | tar -zvt "

I use execlp to run the process.

When i try to run something like cat it works, but if i try to run base64 -d | tar -zvt it doesn’t work.

I looked at the bash commands and I found out that I can run bash and tell him to run other programs. So it’s something like:

execlp ("bash", "-c", "base64 -d | tar -zvt", NULL);

If I run it on the terminal, it works well, but using the execlp it dont work.
If I use execlp("cat", "cat", NULL) it works.

Someone knows how to use the -c param on execlp to execute multiple “programs”?
I cant use system because i use pipe and fork.

Now i noticed, if i try to use execlp(“bash”, “bash”, “-c”, “base64”, NULL)… nothing happens.
If i use execlp(“cat”, NULL) it’s ok..
I’m writing to the stdin… i don’t know if its the problem with the bash -c base64.. because if i run on the terminal echo “asd” | bash -c “cat”
it goes well

  • 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-05-28T02:12:59+00:00Added an answer on May 28, 2026 at 2:12 am

    The first “argument” is what becomes argv[0], so you should call with something like:

    execlp("bash", "bash", "-c", "base64 -d | tar -zvt", NULL);
    

    Edit A small explanation what the above function does: The exec family of functions executes a program. In the above call the program in question is “bash” (first argument). Bash, like all other programs, have a main function that is the starting point of the program. And like all other main functions, the one in Bash receives two arguments, commonly called argc and argv. argv is an array of zero-terminated strings, and argc is the number of entries in the argv array. argc will always be at least 1, meaning that there is always one entry at argv[0]. This first entry is the “name” of the program, most often the path of the program file. All other program arguments on the command line is put into argv[1] to argv[argc - 1].

    What execlp does is use the first argument to find the program to be executed, and all the other arguments will be put into the programs argv array in the order they are given. This means that the above call to execlp will call the program “bash” and set the argv array of Bash to this:

    argv[0] = "bash"
    argv[1] = "-c"
    argv[2] = "base64 -d | tar -zvt"
    

    Also, argc of Bash will be set to 3.

    If the second "bash" is changed to "foo", then argv[0] of Bash will be set to "foo" as well.

    I hope this clears it up a little bit.

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

Sidebar

Related Questions

I want to run a django update through the ORM that looks something like
PROBLEM: I want to run a query which would trigger something like select *
I want a program to do one thing if executed like this: cat something
I want to run a weekly batch process in an asp.net page. How can
Something that happens to me a lot while web programming: I want to run
If I do something like: Dog dog; //class with virtual methods Cat cat; //class
I want to run some code after loading my custom file, but I want
I want to run a function when someone scrolls down on an element. Something
end goal is to have the bash run something like php script.php argument1 argument2
I want run a script as follows: runner: ssh 'java program &' ssh 'java

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.