Jump to content

Τράγου Κέρατο

Mέλη
  • Posts

    3,677
  • Joined

  • Last visited

  • Days Won

    49

Everything posted by Τράγου Κέρατο

  1. Ένα σχετικό άρθρο. A very useful Linux feature is named pipes which enable different processes to communicate. One of the fundamental features that makes Linux and other Unices useful is the ``pipe''. Pipes allow separate processes to communicate without having been designed explicitly to work together. This allows tools quite narrow in their function to be combined in complex ways. A simple example of using a pipe is the command: ls | grep x When bash examines the command line, it finds the vertical bar character | that separates the two commands. Bash and other shells run both commands, connecting the output of the first to the input of the second. The ls program produces a list of files in the current directory, while the grep program reads the output of ls and prints only those lines containing the letter x. The above, familiar to most Unix users, is an example of an ``unnamed pipe''. The pipe exists only inside the kernel and cannot be accessed by processes that created it, in this case, the bash shell. For those who don't already know, a parent process is the first process started by a program that in turn creates separate child processes that execute the program. The other sort of pipe is a ``named'' pipe, which is sometimes called a FIFO. FIFO stands for ``First In, First Out'' and refers to the property that the order of bytes going in is the same coming out. The ``name'' of a named pipe is actually a file name within the file system. Pipes are shown by ls as any other file with a couple of differences: % ls -l fifo1 prw-r--r-- 1 andy users 0 Jan 22 23:11 fifo1| The p in the leftmost column indicates that fifo1 is a pipe. The rest of the permission bits control who can read or write to the pipe just like a regular file. On systems with a modern ls, the | character at the end of the file name is another clue, and on Linux systems with the color option enabled, fifo| is printed in red by default. On older Linux systems, named pipes are created by the mknod program, usually located in the /etc directory. On more modern systems, mkfifo is a standard utility. The mkfifo program takes one or more file names as arguments for this task and creates pipes with those names. For example, to create a named pipe with the name pipe1 give the command: mkfifo pipe The simplest way to show how named pipes work is with an example. Suppose we've created pipe as shown above. In one virtual console1, type: ls -l > pipe1 and in another type: cat < pipe Voila! The output of the command run on the first console shows up on the second console. Note that the order in which you run the commands doesn't matter. If you haven't used virtual consoles before, see the article ``Keyboards, Consoles and VT Cruising'' by John M. Fisk in the November 1996 Linux Journal. If you watch closely, you'll notice that the first command you run appears to hang. This happens because the other end of the pipe is not yet connected, and so the kernel suspends the first process until the second process opens the pipe. In Unix jargon, the process is said to be ``blocked'', since it is waiting for something to happen. One very useful application of named pipes is to allow totally unrelated programs to communicate with each other. For example, a program that services requests of some sort (print files, access a database) could open the pipe for reading. Then, another process could make a request by opening the pipe and writing a command. That is, the ``server'' can perform a task on behalf of the ``client''. Blocking can also happen if the client isn't writing, or the server isn't reading. Pipe Madness Create two named pipes, pipe1 and pipe2. Run the commands: echo -n x | cat - pipe1 > pipe2 & cat <pipe2 > pipe1 On screen, it will not appear that anything is happening, but if you run top (a command similar to ps for showing process status), you'll see that both cat programs are running like crazy copying the letter x back and forth in an endless loop. After you press ctrl-C to get out of the loop, you may receive the message ``broken pipe''. This error occurs when a process writing to a pipe when the process reading the pipe closes its end. Since the reader is gone, the data has no place to go. Normally, the writer will finish writing its data and close the pipe. At this point, the reader sees the EOF (end of file) and executes the request. Whether or not the ``broken pipe'' message is issued depends on events at the exact instant the ctrl-C is pressed. If the second cat has just read the x, pressing ctrl-C stops the second cat, pipe1 is closed and the first cat stops quietly, i.e., without a message. On the other hand, if the second cat is waiting for the first to write the x, ctrl-C causes pipe2 to close before the first cat can write to it, and the error message is issued. This sort of random behavior is known as a ``race condition''. Command Substitution Bash uses named pipes in a really neat way. Recall that when you enclose a command in parenthesis, the command is actually run in a ``subshell''; that is, the shell clones itself and the clone interprets the command(s) within the parenthesis. Since the outer shell is running only a single ``command'', the output of a complete set of commands can be redirected as a unit. For example, the command: (ls -l; ls -l) >ls.out writes two copies of the current directory listing to the file ls.out. Command substitution occurs when you put a < or > in front of the left parenthesis. For instance, typing the command: cat <(ls -l) results in the command ls -l executing in a subshell as usual, but redirects the output to a temporary named pipe, which bash creates, names and later deletes. Therefore, cat has a valid file name to read from, and we see the output of ls -l, taking one more step than usual to do so. Similarly, giving >(commands) results in Bash naming a temporary pipe, which the commands inside the parenthesis read for input. If you want to see whether two directories contain the same file names, run the single command: cmp <(ls /dir1) <(ls /dir2) The compare program cmp will see the names of two files which it will read and compare. Command substitution also makes the tee command (used to view and save the output of a command) much more useful in that you can cause a single stream of input to be read by multiple readers without resorting to temporary files--bash does all the work for you. The command: ls | tee >(grep foo | wc >foo.count) \ >(grep bar | wc >bar.count) \ | grep baz | wc >baz.count counts the number of occurrences of foo, bar and baz in the output of ls and writes this information to three separate files. Command substitutions can even be nested: cat <(cat <(cat <(ls -l)))) works as a very roundabout way to list the current directory. As you can see, while the unnamed pipes allow simple commands to be strung together, named pipes, with a little help from bash, allow whole trees of pipes to be created. The possibilities are limited only by your imagination. ΠΗΓΗ (click)
  2. Αυτό που είχα υπόψη μου, είναι πως ο Απόλλων της μεθόδου και ο Διόνυσος της έμπνευσης είναι ένα και το αυτό κατά την ελληνική θεολογία. Από κει και ύστερα ο Νίτσε το έχει πιάσει το θέμα πολύ καλά και αξίζει να του ρίξουμε μια ματιά (και δύο, και τρεις και ογδονταπέντε).
  3. Είναι και κάποια πράγματα που καλό είναι να τα ψάχνουμε κι από μόνοι μας, ε;
  4. Γιατί το πήρες προσωπικά; Εγώ μιλούσα γενικότερα! :evilbl:
  5. Πάντως την άποψη πως "περνάς σε μια άλλη πραγματικότητα" την βρίσκω ολίγον ευθυνόφοβη. Θα δώσω ένα ακραίο παράδειγμα για να εξηγήσω το γιατί: θέλω να σκοτώσω κάποιον, οπότε επιλέγω να περάσω στην πραγματικότητα στην οποία τον δολοφονώ. *αχέμ* (χώρια που δεν πρόκειται να το δεχτεί αυτό ο δικαστής ως δικαιολογία...)
  6. Ακριβώς, όπως στο χριστιανισμό τους ανθρώπους τους έφτιαξε ο Δίας, έτσι και στην ελληνική θρησκεία. :blblbl: Θα σε δείρω. Μιλάς για τα πέντε γένη του Ησιόδου, άρα για τη συγκεκριμένη αντίληψη. Άλλη αντίληψη λέει πως οι άνθρωποι ήταν και των δύο φύλων ταυτόχρονα. Άλλη παράδοση λέει πως πρώτη γυναίκα ήταν η Πανδώρα. Άλλη παράδοση λέει πως οι άνθρωποι φύτρωσαν από τη Γη (εκτός από τους Έλληνες, σύμφωνα με τους εψιλονιασμένους :headb: ) Ποια από όλες είναι η σωστή; :zipped:
  7. Και πάλι διαφωνώ. Μαθαίνεις, μορφώνεσαι, επιλέγεις ένα μονοπάτι, μια στάση ζωής, μια οπτική. Το πώς θα βλέπεις τα πράγματα εξαρτάται άμεσα από αυτό που θα το ακολουθήσεις. Το να μένεις απ' έξω από κάποιο ρεύμα είναι πνευματική δειλία. Χώρια που ούτως ή άλλως δε γίνεται. Το πλεονέκτημα που έχει ένα παιδί είναι α. το ότι βλέπει όλα τα πράγματα πρώτη φορά (με λίγη εξάσκηση μπορείς να το πετύχεις και μεγαλύτερος, να βλέπεις δηλ. τα πράγματα σαν να τα βλέπεις πρώτη φορά) β. το ότι δε δέχεται τα "αυτονόητα": αυτό είναιπ ιο δύσκολο μια και θέλει τεράστιο θάρρος να αναθεωρήσεις τα αυτονόητά σου κάποια δεδομένη στιγμή. Από την άλλη, αν δεν πατήσεις και σε κάποιες σταθερές, δεν πρόκειται να το κουνήσεις ρούπι από κει που είσαι.
  8. Καλά, ωστόσο αν τα ίδια πράγματα τα είχανε κάνει ιερείς βουντού, αμφιβάλλω αν τα σχόλια θα ήταν τα ίδια.
  9. Όλα αυτά περιγράφονται από τη σχέση Απόλλωνα και Διόνυσου.
  10. Εγώ ξέρω ένα πολύ απλό ξόρκι για να περάσει ΑΜΕΣΩΣ το λεωφορείο. Ανάβεις τσιγάρο. Περνάει μετά από δυο ρουφηξιές.
  11. Η διαίσθηση πολλές φορές είναι σκέψη "στα παρασκήνια" του μυαλού η οποία δηλώνει τα αποτελέσματά της. Εγώ τουλάχιστον έτσι το νοιώθω.
  12. Απαξίωση της μόρφωσης και κολοκύθια τούμπανα... αν είναι έτσι να μείνουμε όλοι αγράμματοι να δούμε το φως το αληθινό...
  13. Μεγάλη μορφή ο Δημόκριτος. Κληρονόμησε μια τεράστια περιουσία από τον πατέρα του. Την κατασπατάλησε γυρνώντας όλον τον τότε γνωστό -και όχι-τόσο-γνωστό - κόσμο. Γύρισε μεστός από εμπειρείες και άφραγκος. Οι Αβδηρίτες είπαν πως τρελλάθηκε και φωνάξανε τον Ιπποκράτη να τον θεραπεύσει. Η γνωμάτευση του Ιπποκράτη ήταν κατηγορηματική : "Οι Αβδηρίτες πάσχουν από τρέλλα κι ο καταλληλότερος να τους θεραπεύσει από αυτήν είναι ο Δημόκριτος". Μέσω της πολύ προσεκτικής παρατήρησης μπορούσε να διακρίνει τις πολύ λεπτές διαφορές και να ξεχωρίσει έτσι π.χ. το κατσικίσιο γάλα από το αγελαδινό απλώς κοιτώντας το. Ή, βλέποντας μια γυναίκα στο δρόμο να τη χαιρετήσει λέγοντας "Χαίρε κόρη" ή "Χαίρε γύναι". Και, πάνω από όλα, περιγράφεται ως "ο γελαστός φιλόσοφος". Ο ίδιος είπε άλλωστε πως το να γιορτάζεις είναι απαραίτητο στη ζωή. Για όλα τα παραπάνω τον θαυμάζω.
  14. Σιγά το μεγάλο ερώτημα! Το μυαλό μας έχει τεράστια ικανότητα επεξεργασίας δεδομένων. Φαντάζεσαι να αντιλαμβανόμασταν όλα τα ερεθίσματα, ακόμα κι αυτά που τώρα μένουν στη σφαίρα του ασυνειδήτου; Θα τζαζεύαμε αυτοστιγμεί! Οπότε δεν είναι κανένας συμπαντικός νόμος (τί βαρύγδουπη έκφραση!).... Εκτός αν είναι συμπαντικός νόμος το "αφού σε χαλάει, για δεν το κόβεις;"
  15. Οι ηθοποιοί (ιερείς του Διονύσου υπενθυμίζω) πρέπει να κάνουν υποχρωτικά το μάθημα της ΟΡΘΟΦΩΝΙΑΣ το οποίο έχει παραμεριστεί τα τελευταία χρόνια διότι-και-καλά εχθρεύεται τις ντοπιολαλιές και δεν ξέρω κι εγώ τι άλλο άσχετο έχουν πει. Η απλούστατη αλήθεια είναι πως αν δεν προφέρεις σωστά τους φθόγγους, ο άλλος δεν πρόκειται να καταλάβει τι λες. Ένα μόνο σχετικό βιβλίο γνωρίζω, από τις εκδόσεις Δωδώνη, του αείμνηστου Νίκου Παπακωνσταντίνου (μέγας θεατρίνος) με τίτλο "Αγωγή του Λόγου - Ορθοφωνία", αρκετά ευμεγέθες ωστόσο! Αυτό περιέχει κάποιους "γλωσσοδέτες" πιο "ψαγμένους" για να βοηθήσουν να διορθώσεις συγκεκριμένα ελαττώματα στην άρθρωση. Ο παρακάτω, ας πούμε, είναι για το φθόγγο - θ - και είχε ακουστεί και στο σήριαλ "Δυο Ξένοι":
  16. Και (λίγο ή πολύ) απατεώνες.... Και πήγαινε ξήγα τη διαφορά στους οπαδούς τους....
  17. Για δες... μου έρχονται τα ονόματα κάποιων μυστών στο νου.... Σάι Μπάμπα.... Μαχαρίσι... Λόμπσανγκ Ράμπα....
  18. Εμότσαρά σε; Ρεφουλιάρα είσαι! (Τώρα το θυμήθηκα)
  19. Το οποίο σημαίνει πως ΚΑΠΟΙΟΙ θέλουν να μην τα συσχετίσουμε! :headb:
  20. Αυτό λέω! Είσαι συνειδητή ορθόδοξη! Πρόβλημά σου! :blblbl: Σε κατηγόρησα για αυτό; Πρόσεξε τώρα: Βαφτισμένη -> βαφτσμένη -> βαφδσμένη -> βαφσμένη -> βαμμένη. (Δεν ξέρω αυτοί οι μετασχηματισμοί πόσα πτυχία γλωσσολογίας "σκίζουν"). Πρόσεξε τώρα: ΒΑΦΤΙΣΜΕΝΗ = 1116 ΒΑΜΜΕΝΗ = 146 Πώς σου φαίνεται; Τυχαίο;
×
×
  • Create New...