@tattyan39

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

html out について。

ps_test1.cgi
#! C:/Program Files/PowerShell/7/pwsh
$OutputEncoding = [System.Text.Encoding]::utf8NoBOM
# http://127.0.0.1/ps_test/ps_test1.cgi
$this_out = @"Content-type: text/html;

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test PowerShell CGI Script</title>
</head>
<body>
<h1>test</h1>
</body>
</html>
"@
cd "C:\Apache\Apache2.2\htdocs\ps_test\"
$thisPath = "ps_test1.cgi"
Start-Process "msedge.exe" $thisPath
"https://localhost/ps_test/" | ForEach-Object { Start-Process "msedge.exe" $thisPath }

exit 0
error.log
[Tue Aug 19 11:56:01 2025] [error] [client 127.0.0.1] Premature end of script headers: ps_test1.cgi
acsesu.log
127.0.0.1 - - [19/Aug/2025:11:56:01 +0900] "GET /ps_test/ps_test1.cgi HTTP/1.1" 500 536

環境 Apache2.2 PowerShell7.6 ブラウザedge

fast try

ps_test.cgi
#! C:/Program Files/PowerShell/7/pwsh
$OutputEncoding = [System.Text.Encoding]::utf8NoBOM
# #! C:/Program Files/PowerShell/7/pwsh -utf8NoBOM
####### test PowerShell 7 コンソール test #######
#  立ち上がり後utf-8化しています。ファイルはutf-8で保存しておいてください。
# この場合UTF8なのかUTF-8なのか抑えた方がいいがシェルコマンドの-は要素となる2要素になる。
#  http://127.0.0.1/ps_test/ps_test.cgi

# これはコメントです
echo Content-type: text/html;
echo 
$hedder = @"<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test PowerShell CGI Script</title>
</head>
<body>
"@
echo $hedder
# body erement
Write-Output "こんにちは"  # これは出力コマンドです
$futtr = @"
</body>
</html>
@"
echo $futtr
# this cgi out last display.
exit 0
# free PowerShell workig.

$html = @"Content-type: text/html;

<html>
<head><title>Test</title></head>
<body><h1>こんにちは、にゃんにゃんさん</h1></body>
</html>
"@
# 生成アドレスへパイプで送り込む 仮想ファイル空間
cd "C:\Apache\Apache2.2\htdocs\ps_test\"
echo 出力待機中。
Read-Host "続行するには Enter キーを押してください"
$tempPath = "ps_test.html"
$html | Set-Content -Path $tempPath -Encoding utf8NoBOM
echo 第二待機、併設ブラウザに出力待ち。
$tempPath = "ps_test.html"
cmd /c pause
Start-Process "msedge.exe" $tempPath
"https://localhost/ps_test/" | ForEach-Object { Start-Process "msedge.exe" $tempPath }

echo 第3待機、ブラウザに出力待ち。何も送らず待機しますこのファイルが起きます。
cmd /c pause
$scriptPath = "C:\Apache\Apache2.2\htdocs\ps_test\my_form_fast.ps1"
& $scriptPath
exit 0

on sell taminal view opne.try.

やってはいますが上手く行きません。

1 likes

1Answer

Comments

  1. @tattyan39

    Questioner

    急いでいたし、そもそも、投稿を押したら変えられなかったのや、ミスタッチもあります。

  2. 投稿内容は編集できますので,必要な情報を追記してください.
    普段の記事も他人が追えるものとは言い難いので,少し見直してから投稿をお願いします.

    on sell taminal view opne.try.
    やってはいますが上手く行きません。

    このような文体では何をしてどうなったのか他人には伝わらないということです.ついでに,用語を正確に覚える努力もお願いします.

  3. @tattyan39

    Questioner

    上手く行くわけがないと、返事を頂ければ。納得します。
    わたしも、うまく行って無いのだから。わたしより高度な技術に至っていない、と言うだけで。。。
    せやな、そんな結果やろなぁ。お疲れ様です。

Your answer might help someone💌