Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unix script to call web page

Posted on 2009-07-01
4
Medium Priority
?
530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month7 days, 22 hours left to enroll

610 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