Solved

Unix script to call web page

Posted on 2009-07-01
4
490 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

895 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

14 Experts available now in Live!

Get 1:1 Help Now