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",
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 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 $version = 'unknown';
131 my $ua = new LWP::UserAgent;
132 $ua->agent("grml-tips 0.0 "); # set the HTTP 'browser' type
134 $ua->post('http://deb.grml.org/~formorer/submissions/keyword.cgi',
135 [ 'version' => $version,
136 'keyword' => $pattern
139 if ($res->is_success) {
140 my $content = $res->decoded_content;
141 if ($content =~ /Submission received/) {
142 print "'$pattern' submitted\n";
144 print "Your pattern could not be submitted.\n",
145 "Please file a bug against grml-tips at ",
146 "http://bts.grml.org.\n",
150 print "Could not submitt '$pattern': " . $res->status_line . "\n";
157 ## END OF FILE #################################################################