startowanie basha z perla
witam,
pytanie z pogranicza perla i basha.
napisalem sobie takie małe badziewko w perlu do logowania poleceń
(pewnie są lepsze rozwiązania, ale takiego czegoś potrzebuję) --
załączam poniżej, może się komuś przyda. Jednego tylko nie wiem: jak
wystartować basha z innym promptem? PS1 jest czytane z .profile (czego
nie chcę zmieniać), więc w jakiś sposób musiałbym bashowi polecić
wykonanie jako pierwszego polecenia PS1="nowy prompt" i czekanie na
dalsze...
j.
#!/usr/bin/perl
# logging specific commands from bash in a user-defined file
use strict ;
use warnings ;
# where to log in the current directory
my $log = ($ARGV[0] or "logger-LOG.TXT") ;
my $if ;
print STDERR "Logging to file $log\n" ;
# get the description
print STDERR "Enter description, press ctrl-d when done:\n" ;
my @desc = readline STDIN ;
# start a new log entry
open($if, ">>$log") or die "Cannot open log file $log:\n$!\n" ;
print $if "-------------\n" ;
printf $if "date: %s\n", `date` ;
print $if join("\n", @desc) ;
printf $if "Commands issued:\n" ;
close $if ;
print STDERR "Enter your command normally; when you are done, press
ctr-d or write 'exit' \n" ;
# change the history file
$ENV{'HISTFILE'} = $log ;
system 'bash' ;
print STDERR "Logging finished\n" ;
--
------------ January Weiner 3 ---------------------+---------------
Division of Bioinformatics, University of Muenster | Schloßplatz 4
(+49)(251)8321634 | D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/ | Germany
Reply to: