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 ################################################################################
20 B<grml-tips> - query a signature file for a specific keyword and display results
24 B<grml-tips> [OPTION] I<keyword>
28 This manual page documents briefly the B<grml-tips> command.
36 Print this help and exit.
44 =item B<grml-tips> I<ntfs>
46 Query grml-tips file for tips / hints including keyword "ntfs".
48 =item B<grml-tips> I<.>
50 Display all available B<grml-tips> at once.
56 /usr/share/grml-tips/grml_tips
58 Signature file containing the tips.
66 grml-tips was written by Alexander Wirt <formorer@grml.org>
71 my $grml_tips = '/usr/share/grml-tips/grml_tips';
76 -message => 'No search pattern provided',
78 } elsif ($pattern eq '--help') {
83 if (! open (my $fh, '<', "$grml_tips")) {
84 say STDERR "Error: File \"$grml_tips\" not found.";
85 say STDERR "Exiting.";
90 while (my $line = <$fh>) {
91 if ($line !~ /^-- $/) {
94 if ( $tip =~ /$pattern/mi ) {
107 if (! open (my $fh, '|-', 'less -FRX') ) {
113 say "Sorry, could not find a tip for '$pattern'. :-(\n\n",
114 "Do you want to submit the keyword '$pattern' to grml's keyword database?\n",
115 "The grml team will write tips for the most requested and useful keywords.\n",
116 "To use and contribute to this feature you'll need a working networking connection.\n",
117 "No personal data will be transmitted to the database.\n\n",
118 "Send \"$pattern\" to grml's keyword database? [y|N] ";
120 ReadMode 4; # Turn off controls keys
122 while (not defined ($x = ReadKey(-1))) {
123 Time::HiRes::sleep(0.5);
125 ReadMode 0; # Reset tty mode before exiting
127 if ($x =~ /(y|j)/i) {
129 if ( -f '/etc/grml_version' ) {
130 open (my $fh, '<', '/etc/grml_version') or die "Could not open /etc/grml_version: $!";
134 } elsif ( -f '/etc/debian_version') {
135 open (my $fh, '<', '/etc/debian_version') or die "Could not open /etc/debian_version: $!";
140 $version = 'unknown';
142 my $ua = new LWP::UserAgent;
143 $ua->agent("grml-tips 0.0 "); # set the HTTP 'browser' type
145 $ua->post('http://deb.grml.org/~formorer/submissions/keyword.cgi',
146 [ 'version' => $version,
147 'keyword' => $pattern
150 if ($res->is_success) {
151 my $content = $res->decoded_content;
152 if ($content =~ /Submission received/) {
153 say "Keyword '$pattern' has been submitted to grml's keyword database.\nThanks.";
155 say "Your pattern could not be submitted.\n",
156 "Please file a bug against grml-tips at ",
157 "http://bts.grml.org/\n",
161 print "Could not submitt '$pattern': " . $res->status_line . "\n";
166 print "'$pattern' has not been sent to grml's keyword database as requested.\n";
167 print "If you want to submit a tip please mail it to tips\@grml.org - thank you!\n";
171 ## END OF FILE #################################################################