Contact:http://www.packetnexus.com
useradd -d /export/home/jlewis -m -c "Jason Lewis" -s /bin/ksh jlewis Back to the Index
Contact:http://www.packetnexus.com
#!/bin/sh
# Stop proftpd by killing the process
echo "Shuting down proftpd"
kill -TERM `ps -ef | grep proftpd | grep -v grep | awk '{print $2}'`
echo "Proftpd shutdown"
Back to the Index
Contact:http://www.packetnexus.com
#!/sbin/sh
#
case "$1" in
'start')
/opt/netscape/mail/slapd-phillip/start-slapd
;;
'stop')
/opt/netscape/mail/slapd-phillip/stop-slapd
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0
Back to the Index
Contact:http://www.packetnexus.com
tohtml.pl: put a HTML wrapper around a text
#!/usr/local/bin/perl
#change a text file to html
$first = 1;
print <html>;
print "\<head\>\n";
while ($line = <>) {
if ($first) {
$first = 0;
print "\<title\>$line\</title\>\n";
print "\</head\>\n";
print "\<body\>\n";
$line =~ s!(.*)!\<h1\>\1\</h1\>!;
print $line;
}
else {
# next 3 lines presume there isn't any html markup already
# in the file
$line =~ s/&/&/g;
$line =~ s/\</</g;
$line =~ s/\>/>/g;
# blank line = new paragraph
$line =~ s/^$/\<p\>/;
print $line;
}
}
print "\</body\>\n";
print "\</html\>\n";
dehtml.pl: strip HTML markup from a text
#!/usr/bin/perl
#strip html tags
while (<>) {
$_ =~ s/<[^>]*>//g;
print;
}
Back to the Index
Contact:http://www.packetnexus.com
GLOBAL REPLACE in the files:
awk '{gsub("call", "mall", $0); print > FILENAME}' *.kumac
change call to mall in all *.kumac files
Back to the Index
Contact:http://www.packetnexus.com
grep for http:// store result as $arg append <a href="http://$arg">Link</a> to end of doc Back to the Index
Contact:http://www.packetnexus.com
#!/bin/perl
#
# Kevin Kadow ([email protected]) <A&NBSP;HREF="HTTP: ? kadow
www.msg.nethttp://www.msg.net/kadow/
# Can be downloaded from <A&NBSP;HREF="HTTP: www.msg.net search.html? small
utilityhttp://www.msg.net/utility/small/search.html
# For 1stomni, free for all to use as long as the comments are kept intact!
#
# Search and replace strings in html files
#
require 'find.pl';
#
# Change these variables as needed.
#
$dir="/export/home/worldwide/htdocs";
$search="http://www.1888wwsports.com/1stomni.com/virtuflex.cgi";
$replace="http://www.1888wwsports.com/phpshop/cart.php3?action=add";
warn <<"EOF";
Starting search/replace script $0
Search all files below $dir
Looking for string $search
Replace the string with $replace
EOF
#
# Do the actual work
#
&find($dir);
warn "Scanned $files making $changes changes.\n";
exit(0);
################ SUBROUTINES FOLLOW #################################
#wanted
#
# This routine is called by 'find', once for each file, directory, etc.
#
sub wanted {
#Skip everything except files named .html or .shtml
return unless( -f $_ && m/\.[s]*html$/);
&update("$dir/$_");
}
#update
#
# Do the search-and-replace on a given file
#
sub update {
local($file)=@_;
local(@contents);
# Open the file for reading and writing (the + does that)
unless(open(FILE,"+<$file")) {
warn "Cannot open $file for updating, Error: $!\n";
return;
}
warn "Updating $file\n";
$files++;
# Read the contents into an array, replacing the string as we go
while ($_=) {
$changes += s/$search/$replace/ig;
push(@contents,$_);
}
# Go to the beginning of the file
seek(FILE,0,0);
# Update the contents with the data from our array
print FILE (@contents);
close(FILE);
}
###EOF###
Back to the Index
Contact:http://www.packetnexus.com
#!/usr/bin/ksh -v #/usr/local/bin/top -n | mailx -s "top output from `hostname`" [email protected] #/usr/bin/df -k | mailx -s "df output from `hostname`" [email protected] #/bin/netstat -an | mailx -s "netstat output from `hostname`" [email protected] echo Established > /tmp/junk.gcd netstat -an | grep -i estab | wc -l >> /tmp/junk.gcd echo Wait >> /tmp/junk.gcd netstat -an | grep -i wait | wc -l >> /tmp/junk.gcd echo Idle >> /tmp/junk.gcd netstat -an | grep -i idle | wc -l >> /tmp/junk.gcd df -k >> /tmp/junk.gcd /usr/local/bin/top -n >> /tmp/junk.gcd /bin/netstat -an >> /tmp/junk.gcd mailx -s "Output from `hostname`" [email protected] < /tmp/junk.gcd Back to the Index
Contact:http://www.packetnexus.com
how i can execute a perl script.
I try some commands like:
exec("perl.pl logfile.log 12-10-2000 13-10-2000 >>log.html");
I try the same with system and the other two commands - but no change -
Have somebody any Idea ???
matthias
Is the 'perl.pl' script executable and readable by the webserver?
Do you specify the correct path as well?
Try executing '/usr/bin/perl perl.pl ........' if that works.
Is your perl interpreter path properly configured in your perl script?
exec -- Execute an external program
Description
string exec (string command [, string array [, int return_var]])
exec() executes the given command, however it does not output anything. It
simply returns the last line from the result of the command. If you need to
execute a command and have all the data from the command passed directly
back without any interference, use the PassThru() function.
If the array argument is present, then the specified array will be filled
with every line of output from the command. Note that if the array already
contains some elements, exec() will append to the end of the array. If you
do not want the function to append elements, call unset() on the array
before passing it to exec().
If the return_var argument is present along with the array argument, then
the return status of the executed command will be written to this variable.
Note that if you are going to allow data coming from user input to be passed
to this function, then you should be using EscapeShellCmd() to make sure
that users cannot trick the system into executing arbitrary commands.
Note also that if you start a program using this function and want to leave
it running in the background, you have to make sure that the output of that
program is redirected to a file or some other output stream or else PHP will
hang until the execution of the program ends.
See also system(), PassThru(), popen(), EscapeShellCmd(), and the backtick
operator.
(from http://www.php.net/manual/function.exec.php
Grtz,
Back to the Index
Contact:http://www.packetnexus.com
You might want to check out: http://www.mysql.com/Manual_chapter/manual_Common_programs.html# Has some info about directly importing apache logs into a mysql database. Back to the Index