3 # Purpose: query a signature file for a specific keyword and display results
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>, (c) Alexander Wirt <formorer@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Sam Mär 03 15:35:38 CET 2007 [mika]
8 ################################################################################
19 B<grml-tips> - query a signature file for a specific keyword and display results
23 B<grml-tips> [OPTION] I<keyword>
27 This manual page documents briefly the B<grml-tips> command.
35 Print this help and exit.
43 =item B<grml-tips> I<ntfs>
45 Query grml-tips file for tips / hints including keyword "ntfs".
47 =item B<grml-tips> I<.>
49 Display all available B<grml-tips> at once.
55 /usr/share/grml-tips/grml_tips
57 Signature file containing the tips.
65 grml-tips was written by Alexander Wirt <formorer@grml.org>
70 my $grml_tips = '/usr/share/grml-tips/grml_tips';
75 -message => 'No search pattern provided',
77 } elsif ($pattern eq '--help') {
83 if (! open ($fh, '<', "$grml_tips")) {
84 print "Error: $grml_tips not found.\nExiting.";
91 while (my $line = <$fh>) {
92 if ($line !~ /^-- $/) {
95 if ( "$tip" =~ /$pattern/mi ) {
108 print "Sorry, could not find a tip for '$pattern'. :-(\n\n",
109 "Do you want to submit the keyword '$pattern' to grml's keyword database?\n",
110 "The grml team will write tips for the most requested and useful keywords.\n",
111 "To use and contribute to this feature you'll need a working networking connection.\n",
112 "No personal data will be transmitted to the database.\n\n",
113 "Send \"$pattern\" to grml's keyword database? [y|N] ";
115 ReadMode 4; # Turn off controls keys
117 while (not defined ($x = ReadKey(-1))) {
118 Time::HiRes::sleep(0.5);
120 ReadMode 0; # Reset tty mode before exiting
122 if ($x =~ /(y|j)/i) {
124 if ( -f '/etc/grml_version' ) {
125 open (my $fh, '<', '/etc/grml_version') or die "Could not open /etc/grml_version: $!";
129 } elsif ( -f '/etc/debian_version') {
130 open (my $fh, '<', '/etc/debian_version') or die "Could not open /etc/debian_version: $!";
135 $version = 'unknown';
137 my $ua = new LWP::UserAgent;
138 $ua->agent("grml-tips 0.0 "); # set the HTTP 'browser' type
140 $ua->post('http://deb.grml.org/~formorer/submissions/keyword.cgi',
141 [ 'version' => $version,
142 'keyword' => $pattern
145 if ($res->is_success) {
146 my $content = $res->decoded_content;
147 if ($content =~ /Submission received/) {
148 print "Keyword '$pattern' has been submitted to grml's keyword database.\nThanks.\n";
150 print "Your pattern could not be submitted.\n",
151 "Please file a bug against grml-tips at ",
152 "http://bts.grml.org/\n",
156 print "Could not submitt '$pattern': " . $res->status_line . "\n";
161 print "'$pattern' has not been sent to grml's keyword database as requested.\n";
162 print "If you want to submit a tip please mail it to tips\@grml.org - thank you!\n";
166 ## END OF FILE #################################################################