Solved

Unix script to call web page

Posted on 2009-07-01
4
479 Views
Last Modified: 2012-05-07
I have a sample script given to me by a vendor for calling a function on a web site to retreive a pdf/csv file.

It creates a request


export REQUEST_METHOD=GET export QUERY_STRING="OUTPUT_FMT=CSV&FM_CODE=mlaf070&USER_PROF=OLSOJ25&RPT_
FMT=N&PAPER_SIZE=LETTER&ORIENTATION=P&LINES_PER_INCH=8&RPT_FONT_SIZE=medium"

then it calls another script /cgi-bin/ma.sh ( I dont have access to this folder so I have copied it to a local folder)

when I call it it doesnt seem to do anything, my guess is that I need to execute the file "/cgi-bin/ma.sh" from the web folder location does that make sense? or should the script work from any location?






0
Comment
Question by:JonMny
  • 2
  • 2
4 Comments
 
LVL 14

Expert Comment

by:sjm_ee
ID: 24754954
Please post the "ma.sh" script.
0
 
LVL 9

Author Comment

by:JonMny
ID: 24755009


#
# source .profile to set all of the required  environment varis.
#
. ~/.profile
# get the request id value from the query string
_REQUEST_ID=`echo \$QUERY_STRING | sed -e "s/.*REQUEST_ID=\\([^&]*\\).*/\\1/"`
 
# I changed this
_FILENAME=/tmp/userlist.csv  
if [ -e $_FILENAME ]
then
    # note: the file we'll dump out has an HTTP header on the front of it.
    cat $_FILENAME
    rm -f $_FILENAME
else
    echo "Content-type: text/plain"
    echo ""
    echo "Document not avail"
    exit 0
fi

0
 
LVL 14

Accepted Solution

by:
sjm_ee earned 500 total points
ID: 24755684
This script looks like it is supposed to be run as a CGI bin on the web server - it outputs MIME headers and data to a web browser. The way to invoke the script would be to type the following into your web browser:

http://<ip name>/cgi-bin/ma.sh

The exact invocation will depend on how your webserver is setup.
0
 
LVL 9

Author Comment

by:JonMny
ID: 24755802
that's correct, the script is supposed to fake a web request, I think I found the problem.
I am able to call the script the only problem is the environment variables, are those stored in a config for apache?
 
 
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now