שלום לכולם יש לי סקריפט בשפת perl (בסביבת לינוקס) אני רוצה לקבל פרמטרים ממערכת ההפעלה: SCRIPT-NAME -F JKJJ -B JKL אני רוצה לקבל את ה- JKJJ וה- JKL לתוך שתי משתנים רעיונות ? תודה
הארגומנטים נגישים בתוך ARGV@, כש-0 הוא הפרמטר הראשון. בסקריפט פשוט זה עשוי להספיק לך. אם הטיפול בפרמטרים מתחיל להיות מורכב, תשתמש במודול Getopt::Long או Getopt::Std.
להפריד את המקדם (-f) לערך ? לדוגמא אני מריץ את האפליקציה עם: app -f "bla bla" אני רוצה שבמקרה של -f לתוך משתנה מסויים יכנס הערך (bla bla) תודה על העזרה
התהליך מתחיל ב- bash script, ומהסקריפט אני קורא לפרל, אני מעוניין להעביר לפרל string עם רווחים, ניסיתי להעביר בתוך גרש ואו גרשיים וכלום הוא מזהה את הרווחים כמפריד בין פרמטרים. איך אני יכול להעביר מחרוזת עם רווחים לסקריפט פרל ? תודה
use Getopt::Std; my %options; getopts("F:f:S:s:m:t:", \%options); $mailfrom = $options{F}; # real Email address of the sender $from =$options{f}; # the display name of the sender $smtpserver = $options{s}; # IP of the smtp server $subject = $options{S}; # subject of the Email $msg =$options{m}; # the message of the Email $mailto = $options{t}; # real email address of the recipient a.pl -f "bla bla" -m "message " .... הצרה החדשה שהוא מזהה את הרווחים כפרמטר חדש למה ואיך אפשר להתגבר על זה ?
use Getopt::Std; my %options; getopts("F:f:S:s:m:t:", \%options); $mailfrom = $options{F}; # real Email address of the sender $from =$options{f}; # the display name of the sender $smtpserver = $options{s}; # IP of the smtp server $subject = $options{S}; # subject of the Email $msg =$options{m}; # the message of the Email $mailto = $options{t}; # real email address of the recipient print "\nmailfrom = $mailfrom\n"; print "from= $mailfrom\n"; print "to= $mailto\n"; print "whoisme= $from\n"; print "subject= $subject\n"; print "msg= $msg\n"; print "smtpsrver= $smtpserver \n"; print "Content-type: text/plain", "\n\n";
use Getopt::Std; my %options; getopts("F:f:S:s:m:t:", \%options); $mailfrom = $options{F}; # real Email address of the sender $from =$options{f}; # the display name of the sender $smtpserver = $options{s}; # IP of the smtp server $subject = $options{S}; # subject of the Email $msg =$options{m}; # the message of the Email $mailto = $options{t}; # real email address of the recipient print "\nmailfrom = $mailfrom\n"; print "from= $mailfrom\n"; print "to= $mailto\n"; print "whoisme= $from\n"; print "subject= $subject\n"; print "msg= $msg\n"; print "smtpsrver= $smtpserver \n"; print "Content-type: text/plain", "\n\n";