Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 03:54

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Shell -> Pipes

Discussion on Shell -> Pipes within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
Belur's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 3,441
Received Thanks: 1,473
Shell -> Pipes

Hey,

bin zur Zeit dabei eine eigene Shell zu schreiben.
Hänge im Moment ein bisschen bei den Pipes:

Das grundlegende Modell der Shell sieht so aus, dass erstmal der Befehl eingelesen wird und dann in einer 2dimensionalen Liste gespeichert wird.
In etwa so:

Also praktisch eine Liste mit Knoten für die Kommandos und jeder Knoten hat noch eine Liste mit Argumenten.

Am Ende wird die Liste dann abgearbeitet.
Ein Befehl wie
Code:
ls -l | grep Test
geht auch durch. Allerdings unterstützt die Shell bislang nur eine Pipe.

Das ganze läuft bislang so:
Wenn beim Durchlaufen der Liste eine Pipe erkannt wird, dann wird folgende Funktion mit dem Knoten vor der Pipe und dem Knoten hinter der Pipe aufgerufen:

Code:
int pipeCommand(struct node_cmd *first, struct node_cmd *second) {
	struct node_arg *tempArg = first->args->start;
	char *args[first->args->length + 1];
        //Array mit den Argumenten aus der args-Liste wird erzeugt.

	struct node_arg *tempArg2 = second->args->start;
	char *args2[second->args->length + 1];
        //Array mit den Argumenten aus der args-Liste wird erzeugt.
	
        int pipefd[2];
	if (pipe(pipefd) == -1) {
		printf("Creating pipe failed\n");
		return -1;
	}

	if (fork() == 0) {
		close(pipefd[0]);
		dup2(pipefd[1], 1);
		return execv(args[0], args);
	}

	if (fork() == 0) {
		close(pipefd[1]);
		dup2(pipefd[0], 0);
		return execv(args2[0], args2);
	}

	close(pipefd[0]);
	close(pipefd[1]);

	while (wait(NULL) >= 0)
		;
}
Das läuft auch soweit alles, allerdings weiß ich nicht genau wie man unendlich viele Pipes umsetzen soll. Ich befürchte dafür muss man eine komplett neue Funktion schreiben bzw irgendwie rekursiv aufrufen?

Vllt hat jemand eine Idee, wie man das am besten umsetzt.

Grüße
Belur is offline  
Reply


Similar Threads Similar Threads
Big Release Skype IP Resoulver IP STresser HTML code Stealer UDP Shell TCP Shell and
01/31/2014 - Coders Trading - 5 Replies
Hello and Welcome to our Website. We Released the Hacking Tool i-NetTool's on our Website at the Button (i-NetTool Release V2) You can choose at the Form for an Free & Premium Version The Free Version have 3 Funtions & the Premium Version 7. After Payed i will send u the Username and Password. Note: We only accept Paysafecard's Premium Version cost: 10€ Free Version : 0€ Selled Times: 11
[C++/Vb.net] Pipes
05/23/2012 - General Coding - 0 Replies
Hallo ich versuche eine Pipe Verbindung zwischen c++ und vb.net herzustellen, aber leider bekomme ich keine verbindung, hier der code: c++ client #include <windows.h> #include <stdio.h> #include <iostream> using namespace std; LPCWSTR GetPipeName()
Get into Mana Pipes
05/11/2007 - WoW Exploits, Hacks, Tools & Macros - 6 Replies
Heya lovely people of xxxxx I was looking a bit around, and noticed quite a few bugs/exploits concentrates around the "Auto-Unstuck" feature. So I thought " wonder if you can get int othe mana pipes in Netherstorm", and I did get into them :P 1. Simply, just drop down infront of one. http://images7.pictiger.com/images/39/142e...5f34 f223039.jpg 2. Use the Auto-Unstuck feature, found under GM help issues (Subject: "Stuck")



All times are GMT +1. The time now is 03:55.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.