Llaverola Posted February 28, 2008 at 05:48 PM Report Share #169669 Posted February 28, 2008 at 05:48 PM bem, a minha duvida tem a ver com programação em linux avançada. fix um trabalho, onde tive de criar 4 pipes e 5 filhos (forks e pipes). cada filho troca uma vogal. ou seja o 1º filho muda a vogal "a", o segundo a vogal "e" e por aí a diante. no ultimo ficlho é imprimido pro terminal a string com as vogais em maiusculas q é o k cada filho faz ( passar a vogal respectiva para maiuscula" agora sei que com o comando: ./work < testefile.txt em vez de escrever pro terminal escreve pro ficheiro... como fazer isso? sei q é no ultimo filho, estou a csg criar o ficheiro, so n csg escrever para ele, obrigado Link to comment Share on other sites More sharing options...
Hipnoted Posted February 28, 2008 at 06:00 PM Report Share #169671 Posted February 28, 2008 at 06:00 PM Para escreveres para o ficheiro tens de fazer o contrário, usando o >. system("ls > ficheiro.txt") (a listagem dos ficheiros no presente directório é escrita para o ficheiro ficheiro.txt) Mas isso depende de como tenhas isso, é difícil dizer-te sem saber ao certo o que estás a fazer. "Nunca discutas com um idiota. Eles arrastam-te até ao seu nível e depois ganham-te em experiência" Link to comment Share on other sites More sharing options...
Llaverola Posted February 28, 2008 at 06:20 PM Author Report Share #169673 Posted February 28, 2008 at 06:20 PM eu usei algo do genero: FILE * fd; close(fds4[0]); fd = open("testfile.txt",O_WRITE|O_READ,0664); dup2(fd,1); fds4 é o pipe que liga o 4º filho ao 5º ou seja, o da letra "o" À letra "u"..... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now