pwd

pwd

You are currently viewing a revision titled "pwd", saved on 2025年6月10日 10:22 PM by fittingmind
タイトル
pwd
コンテンツ
<code> #!/usr/bin/python3 # -*- coding: utf-8 -*- import os import sys import io import cgitb # デバッグ用(エラーをブラウザに表示) cgitb.enable() # 日本語対応 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') # フルパス取得 script_path = os.path.abspath(__file__) print("Content-Type: text/html; charset=utf-8\n") print("<html><head><title>フルパス表示</title></head><body>") print("<h2>このCGIのフルパス:</h2>") print(f"<p>{script_path}</p>") print("</body></html>") -------------------------------------- per バージョン(pl) #!/usr/bin/perl use strict; use warnings; print "Content-Type: text/html; charset=utf-8\n\n"; # フルパス取得 my $script_path = $ENV{'SCRIPT_FILENAME'} || $ENV{'PATH_TRANSLATED'} || 'パス不明'; print <<"HTML"; <!DOCTYPE html> <html> <head><meta charset="UTF-8"><title>フルパス確認</title></head> <body> <h2>このCGIのフルパス:</h2> <p>$script_path</p> </body> </html> ーーーーーーーーーーーーーーーーーーーーーーーー PHPバージョン <?php // Content-Typeを明示 header("Content-Type: text/html; charset=utf-8"); // スクリプトのフルパス取得 $script_path = $_SERVER['SCRIPT_FILENAME'] ?? '不明'; ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>PHPでフルパス確認</title> </head> <body> <h2>このPHPファイルのフルパス:</h2> <p><?php echo htmlspecialchars($script_path, ENT_QUOTES, 'UTF-8'); ?></p> </body> </html> </code>  
抜粋
脚注


Old New Date Created Author Actions
2025年6月10日 1:22 PM fittingmind

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です