in reply to Can a POST command (with a file attachment) be simulated via the terminal?

If you want to run your script on some kind of server, you can automate the POST request via curl, wget or a Perl program.

If you want to run the script as a CGI script from the command line, you can supply the parameters on the command line:

perl myscript.cgi userid=5378 username=Corion

If you use some module other than CGI, please tell us which module you're using and also consider posting a relevant short self-contained example so we can easily try out and verify our approaches.

Replies are listed 'Best First'.
Re^2: Can a POST command (with a file attachment) be simulated via the terminal?
by Danny (Chaplain) on Jun 05, 2024 at 14:01 UTC
    Alternatively, if you only need to debug what the script is doing with the data and not how it is getting the data, you can create a command line flag that tells the script to get the params from a file in whatever format you want to define. If the flag is set just populate the params from the file instead of CGI or whatever you are using.

    EDIT: You can already do this with a file and 'use CGI "-debug"' if your file has lines like param1=value1. script.pl < param_file.txt