LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1675|回复: 3

这段代码的图形为什么显示不出来呢?

[复制链接]
发表于 2004-1-8 17:11:49 | 显示全部楼层 |阅读模式
下面是一段显示登录校验码的程序。用的是perl的Image::Magick模块。
可是为什么显示不出图形来呢?大家看看是不是有什么错误?

是在Debian的系统下。


use Image::Magick;
use MD5;

my $image = new Image::Magick(size => '80x20');
my $code = "";
my @chars = ('a'..'z');
for (1..6) { $code .= $chars[rand(10)]; }
my $codee = MD5->hexhash("$code"."dddd");

$image->Read('xc:#F0C0C0');
$image->Annotate(font=>'arial.ttf', text=>$code, fill=>'black', pointsize=>15, gravit$
$image->Write("$cfg{'nonCgiDir'}/login/$codee.gif");
undef $image;
 楼主| 发表于 2004-1-9 11:33:23 | 显示全部楼层
可是我这段代码是freebsd下运行得很好的。

下面我的Debian系统中装的模块。

/usr/lib/perl5/Mysql.pm; /DBI.pm; /mod_perl.pm; /mod_perl_hooks.pm; /Apache.pm; /Image/Magick.pm; /Apache/SizeLimit.pm; /Apache/Registry.pm; /Apache/RegistryNG.pm; /Apache/Resource.pm; /Apache/RedirectLogFix.pm; /Apache/PerlSections.pm; /Apache/PerlRun.pm; /Apache/Debug.pm; /Apache/MyConfig.pm; /Apache/ExtUtils.pm; /Apache/httpd_conf.pm; /Apache/src.pm; /Apache/SIG.pm; /Apache/Options.pm; /Apache/Symdump.pm; /Apache/Opcode.pm; /Apache/Status.pm; /Apache/RegistryBB.pm; /Apache/Include.pm; /Apache/StatINC.pm; /Apache/FakeRequest.pm; /Apache/test.pm; /Apache/RegistryLoader.pm; /Apache/Connection.pm; /Apache/Constants.pm; /Apache/File.pm; /Apache/Leak.pm; /Apache/Log.pm; /Apache/ModuleConfig.pm; /Apache/PerlRunXS.pm; /Apache/Server.pm; /Apache/Symbol.pm; /Apache/Table.pm; /Apache/URI.pm; /Apache/Util.pm; /Apache/Constants/Exports.pm; /HTML/HeadParser.pm; /HTML/Tagset.pm; /HTML/LinkExtor.pm; /HTML/PullParser.pm; /HTML/Parser.pm; /HTML/Entities.pm; /HTML/TokeParser.pm; /HTML/Filter.pm; /MIME/QuotedPrint.pm; /MIME/Base64.pm; /Digest/MD5.pm; /Mysql/Statement.pm; /DBI/ProxyServer.pm; /DBI/Changes.pm; /DBI/Format.pm; /DBI/Shell.pm; /DBI/FAQ.pm; /DBI/W32ODBC.pm; /DBI/DBD.pm; /DBD/Proxy.pm; /DBD/NullP.pm; /DBD/ExampleP.pm; /DBD/Sponge.pm; /DBD/mysql.pm; /Bundle/Apache.pm; /Bundle/DBI.pm; /Bundle/DBD/mysql.pm; /Win32/DBIODBC.pm;
/usr/share/perl5/URI.pm; /DebianNet.pm; /LWP.pm; /MD5.pm; /Devel/Symdump.pm; /Devel/Symdump/Export.pm; /LWP/ConnCache.pm; /LWP/Protocol.pm; /LWP/MemberMixin.pm; /LWP/RobotUA.pm; /LWP/UserAgent.pm; /LWP/Simple.pm; /LWP/Debug.pm; /LWP/MediaTypes.pm; /LWP/Protocol/mailto.pm; /LWP/Protocol/nntp.pm; /LWP/Protocol/ftp.pm; /LWP/Protocol/GHTTP.pm; /LWP/Protocol/data.pm; /LWP/Protocol/https10.pm; /LWP/Protocol/nogo.pm; /LWP/Protocol/http10.pm; /LWP/Protocol/https.pm; /LWP/Protocol/file.pm; /LWP/Protocol/gopher.pm; /LWP/Protocol/http.pm; /LWP/Authen/Digest.pm; /LWP/Authen/Basic.pm; /HTTP/Negotiate.pm; /HTTP/Cookies.pm; /HTTP/Daemon.pm; /HTTP/Status.pm; /HTTP/Message.pm; /HTTP/Headers.pm; /HTTP/Request.pm; /HTTP/Response.pm; /HTTP/Date.pm; /HTTP/Request/Common.pm; /HTTP/Headers/Util.pm; /HTTP/Headers/Auth.pm; /HTTP/Headers/ETag.pm; /Bundle/LWP.pm; /WWW/RobotRules.pm; /WWW/RobotRules/AnyDBM_File.pm; /File/Listing.pm; /URI/mailto.pm; /URI/pop.pm; /URI/Heuristic.pm; /URI/_generic.pm; /URI/file.pm; /URI/_login.pm; /URI/snews.pm; /URI/http.pm; /URI/rsync.pm; /URI/nntp.pm; /URI/_foreign.pm; /URI/news.pm; /URI/URL.pm; /URI/Escape.pm; /URI/ftp.pm; /URI/_segment.pm; /URI/data.pm; /URI/ssh.pm; /URI/telnet.pm; /URI/ldap.pm; /URI/_userpass.pm; /URI/_query.pm; /URI/_server.pm; /URI/WithBase.pm; /URI/gopher.pm; /URI/rlogin.pm; /URI/https.pm; /URI/file/Win32.pm; /URI/file/Base.pm; /URI/file/Mac.pm; /URI/file/OS2.pm; /URI/file/QNX.pm; /URI/file/FAT.pm; /URI/file/Unix.pm; /HTML/TreeBuilder.pm; /HTML/Element.pm; /HTML/Parse.pm; /HTML/AsSubs.pm; /HTML/Tree.pm; /HTML/Form.pm; /HTML/Element/traverse.pm; /Net/POP3.pm; /Net/Domain.pm; /Net/SMTP.pm; /Net/Time.pm; /Net/NNTP.pm; /Net/Cmd.pm; /Net/Netrc.pm; /Net/FTP.pm; /Net/Config.pm; /Net/HTTP.pm; /Net/HTTPS.pm; /Net/HTTP/Methods.pm; /Net/HTTP/NB.pm; /Net/FTP/dataconn.pm; /Net/FTP/L.pm; /Net/FTP/E.pm; /Net/FTP/A.pm; /Net/FTP/I.pm; /Debian/AdduserCommon.pm; /Debian/Debhelper/Dh_Getopt.pm; /Debian/Debhelper/Dh_Lib.pm; /Debian/Debhelper/Dh_Version.pm; /Debian/DebConf/Client/ConfModule.pm; /Debconf/AutoSelect.pm; /Debconf/Base.pm; /Debconf/ConfModule.pm; /Debconf/Config.pm; /Debconf/Db.pm; /Debconf/DbDriver.pm; /Debconf/Element.pm; /Debconf/Format.pm; /Debconf/FrontEnd.pm; /Debconf/Gettext.pm; /Debconf/Iterator.pm; /Debconf/Log.pm; /Debconf/Priority.pm; /Debconf/Question.pm; /Debconf/Template.pm; /Debconf/TmpFile.pm; /Debconf/Template/Transient.pm; /Debconf/FrontEnd/Dialog.pm; /Debconf/FrontEnd/Editor.pm; /Debconf/FrontEnd/Gnome.pm; /Debconf/FrontEnd/Noninteractive.pm; /Debconf/FrontEnd/Passthrough.pm; /Debconf/FrontEnd/Readline.pm; /Debconf/FrontEnd/ScreenSize.pm; /Debconf/FrontEnd/Teletype.pm; /Debconf/FrontEnd/Text.pm; /Debconf/FrontEnd/Web.pm; /Debconf/Format/822.pm; /Debconf/Element/Gnome.pm; /Debconf/Element/Multiselect.pm; /Debconf/Element/Noninteractive.pm; /Debconf/Element/Select.pm; /Debconf/Element/Web/Boolean.pm; /Debconf/Element/Web/Multiselect.pm; /Debconf/Element/Web/Note.pm; /Debconf/Element/Web/Password.pm; /Debconf/Element/Web/Select.pm; /Debconf/Element/Web/String.pm; /Debconf/Element/Web/Text.pm; /Debconf/Element/Teletype/Boolean.pm; /Debconf/Element/Teletype/Multiselect.pm; /Debconf/Element/Teletype/Note.pm; /Debconf/Element/Teletype/Password.pm; /Debconf/Element/Teletype/Select.pm; /Debconf/Element/Teletype/String.pm; /Debconf/Element/Teletype/Text.pm; /Debconf/Element/Noninteractive/Select.pm; /Debconf/Element/Noninteractive/Note.pm; /Debconf/Element/Gnome/Boolean.pm; /Debconf/Element/Gnome/Multiselect.pm; /Debconf/Element/Gnome/Note.pm; /Debconf/Element/Gnome/Password.pm; /Debconf/Element/Gnome/Select.pm; /Debconf/Element/Gnome/String.pm; /Debconf/Element/Gnome/Text.pm; /Debconf/Element/Editor/Boolean.pm; /Debconf/Element/Editor/Multiselect.pm; /Debconf/Element/Editor/Note.pm; /Debconf/Element/Editor/Password.pm; /Debconf/Element/Editor/Select.pm; /Debconf/Element/Editor/String.pm; /Debconf/Element/Editor/Text.pm; /Debconf/Element/Dialog/Boolean.pm; /Debconf/Element/Dialog/Multiselect.pm; /Debconf/Element/Dialog/Note.pm; /Debconf/Element/Dialog/Password.pm; /Debconf/Element/Dialog/Select.pm; /Debconf/Element/Dialog/String.pm; /Debconf/Element/Dialog/Text.pm; /Debconf/DbDriver/LDAP.pm; /Debconf/DbDriver/Backup.pm; /Debconf/DbDriver/Cache.pm; /Debconf/DbDriver/Copy.pm; /Debconf/DbDriver/Debug.pm; /Debconf/DbDriver/DirTree.pm; /Debconf/DbDriver/Directory.pm; /Debconf/DbDriver/File.pm; /Debconf/DbDriver/Pipe.pm; /Debconf/DbDriver/Stack.pm; /Debconf/Client/ConfModule.pm;
/usr/lib/perl/5.6.1/Config.pm; /DynaLoader.pm; /Errno.pm; /Fcntl.pm; /IO.pm; /POSIX.pm; /Socket.pm; /XSLoader.pm; /ByteLoader.pm; /re.pm; /B.pm; /O.pm; /GDBM_File.pm; /DB_File.pm; /NDBM_File.pm; /ODBM_File.pm; /Opcode.pm; /Safe.pm; /ops.pm; /SDBM_File.pm; /attrs.pm; /IPC/Semaphore.pm; /IPC/Msg.pm; /IPC/SysV.pm; /B/Assembler.pm; /B/Debug.pm; /B/Concise.pm; /B/C.pm; /B/Bblock.pm; /B/CC.pm; /B/Disassembler.pm; /B/Bytecode.pm; /B/Terse.pm; /B/Deparse.pm; /B/Stash.pm; /B/Showlex.pm; /B/Lint.pm; /B/Asmdata.pm; /B/Stackobj.pm; /B/Xref.pm; /Sys/Hostname.pm; /Sys/Syslog.pm; /Devel/DProf.pm; /Devel/Peek.pm; /IO/File.pm; /IO/Handle.pm; /IO/Pipe.pm; /IO/Seekable.pm; /IO/Select.pm; /IO/Socket.pm; /IO/Poll.pm; /IO/Dir.pm; /File/Glob.pm; /Data/Dumper.pm;
/usr/share/perl/5.6.1/AutoLoader.pm; /Carp.pm; /Cwd.pm; /Exporter.pm; /FileHandle.pm; /SelectSaver.pm; /Symbol.pm; /attributes.pm; /base.pm; /constant.pm; /fields.pm; /integer.pm; /lib.pm; /locale.pm; /overload.pm; /strict.pm; /vars.pm; /warnings.pm; /AnyDBM_File.pm; /AutoSplit.pm; /Benchmark.pm; /CGI.pm; /CPAN.pm; /DB.pm; /DirHandle.pm; /Dumpvalue.pm; /English.pm; /Env.pm; /Fatal.pm; /FileCache.pm; /FindBin.pm; /SelfLoader.pm; /Shell.pm; /Test.pm; /UNIVERSAL.pm; /autouse.pm; /blib.pm; /bytes.pm; /charnames.pm; /diagnostics.pm; /filetest.pm; /less.pm; /open.pm; /sigtrap.pm; /subs.pm; /utf8.pm; /CGI/Apache.pm; /CGI/Carp.pm; /CGI/Cookie.pm; /CGI/Pretty.pm; /CGI/Push.pm; /CGI/Switch.pm; /CGI/Util.pm; /CPAN/FirstTime.pm; /CPAN/Nox.pm; /Class/Struct.pm; /Devel/SelfStubber.pm; /I18N/Collate.pm; /Math/BigFloat.pm; /Math/BigInt.pm; /Math/Complex.pm; /Math/Trig.pm; /Net/hostent.pm; /Net/Ping.pm; /Net/netent.pm; /Net/protoent.pm; /Net/servent.pm; /Pod/Functions.pm; /Pod/Checker.pm; /Pod/Find.pm; /Pod/InputObjects.pm; /Pod/Html.pm; /Pod/ParseUtils.pm; /Pod/LaTeX.pm; /Pod/Man.pm; /Pod/ParseLink.pm; /Pod/Parser.pm; /Pod/Plainer.pm; /Pod/Select.pm; /Pod/Text.pm; /Pod/Usage.pm; /Pod/Text/Overstrike.pm; /Pod/Text/color.pm; /Pod/Text/Termcap.pm; /Search/Dict.pm; /Term/ANSIColor.pm; /Term/Cap.pm; /Term/Complete.pm; /Term/ReadLine.pm; /Test/Harness.pm; /Tie/SubstrHash.pm; /Tie/Array.pm; /Tie/Handle.pm; /Tie/Hash.pm; /Tie/RefHash.pm; /Tie/Scalar.pm; /Time/localtime.pm; /Time/Local.pm; /Time/gmtime.pm; /Time/tm.pm; /User/grent.pm; /User/pwent.pm; /ExtUtils/Installed.pm; /ExtUtils/Command.pm; /ExtUtils/Embed.pm; /ExtUtils/Install.pm; /ExtUtils/MM_Cygwin.pm; /ExtUtils/Liblist.pm; /ExtUtils/MakeMaker.pm; /ExtUtils/MM_OS2.pm; /ExtUtils/MM_Unix.pm; /ExtUtils/MM_VMS.pm; /ExtUtils/MM_Win32.pm; /ExtUtils/Mkbootstrap.pm; /ExtUtils/Manifest.pm; /ExtUtils/Mksymlists.pm; /ExtUtils/Packlist.pm; /ExtUtils/testlib.pm; /ExtUtils/Miniperl.pm; /warnings/register.pm; /Text/Tabs.pm; /Text/Wrap.pm; /Text/ParseWords.pm; /Text/Abbrev.pm; /Text/Soundex.pm; /IPC/Open2.pm; /IPC/Open3.pm; /IO/Socket/INET.pm; /IO/Socket/UNIX.pm; /Getopt/Long.pm; /Getopt/Std.pm; /File/Spec.pm; /File/CheckTree.pm; /File/Basename.pm; /File/Compare.pm; /File/Copy.pm; /File/DosGlob.pm; /File/Find.pm; /File/Path.pm; /File/Temp.pm; /File/stat.pm; /File/Spec/Unix.pm; /File/Spec/Functions.pm; /File/Spec/Epoc.pm; /File/Spec/Win32.pm; /File/Spec/Mac.pm; /File/Spec/OS2.pm; /File/Spec/VMS.pm; /Exporter/Heavy.pm; /Carp/Heavy.pm;

另外,您写的这两段代码我无法运行,错误信息如下:
malformed header from script.
Bad header=Perl         -- 5.6.1


devel 在 01-08-2004 14:45 写下了以下信息:
看了你的贴。
http://www.linuxsir.cn/forum.php?mod=viewthread&tid=83899
Image::Magick我装不上。
不知道缺了什么模块还没装。
rand(26)那里可能错了。
应该先种下种子。
example:

#!/usr/bin/perl -w
srand;
$a=int(rand(12));
print "$a\n";

请帮帮忙,要是你愿意,我需要看看你的系统安装有什么PERL模块,用这个脚本,然后我就按照你的装上试试:
#!/usr/bin/perl
use strict;
use ExtUtils::Installed;

my $inst= ExtUtils::Installed->new();
my @modules = $inst->modules();

foreach(@modules)
{
        my $ver = $inst->version($_) || "???";
        printf("%-12s --  %s\n", $_, $ver);
}
exit 0;



:thank :thank
 楼主| 发表于 2004-1-9 11:42:02 | 显示全部楼层
运行这段代码后,在apache的错误日志中,还有以下消息出现:
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found
sh: gs: command not found

这表示什么意思,会不会是这个的原因?
 楼主| 发表于 2004-1-9 11:58:19 | 显示全部楼层
OK,问题已经解决。
sh: gs: command not found
这个应该是表示PostScript Type没有安装的问题。
我用
apt-get install gs-cjk-resource ttf2pt1 后登录校验码就显示出来了。

我个人估计是原先是因为没有安装那个'arial.ttf'字体文件,或是因为根本没有字体可用,所以'a'..'z'这些字母显示不出来,实际上代码已经运行了,但没有字体,所以字母没法显示。

以后还得多用google啊,我这个就是通过google搜索“sh: gs: command not found”找到解决办法的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表