Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a filename to a Unix Shell Script

Status
Not open for further replies.

shelts

Programmer
Feb 12, 2004
20
GB
Anyone know how to pass a filename to a Unix Shell script using the GET("SHL"...) function.

The shell script works fine on the command line:
>sh Listener_Unzip filename_to_unzip

I've tried every command option for the shell adapter, but cannot get it to successfully pass the filename.
 
Did you try PUT? Better yet, use another output card and have the file name in the data, and the shell adapter as the target of the card. I even saw one customer create the shell script on the fly in one output card (will everything needed in the script) Card scope set to card, and then call the script in the next card.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
Thanks Boca. The only thing I've been able to get to work is making sure that the Script and filename being called are surrounded by SYMBOL(34) (quotes).

e.g. "-CMD " + SYMBOL(34) + "Script_Name " + file_to_pass + SYMBOL(34)
 
BTW, to get the script to work when creating on the fly, you need another card to chmod +x the new script.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
Here is an example of a map rule that we are using
=PUT("SHL", "-CMD /exl/mercator/soup/customers/xxx/scripts/xmit.sh -INLINE", GETRESOURCENAME(bod_out))
 
I did try using the -INLINE option, but still couldn't get it to pass the filename to the script, although I was using GET rather than PUT.
 
I would do the GETRESOURCENAME in a previous rule or card and pass the result to the script. Make sure the file is not locked (ie. set to delete on success).

Again, easier to do if the SHELL adapter is the target of the card than a PUT or GET rule. PUT & GET have limited error handling.

You might want to add a -T to see what is being passed, and add something to the shell script to write what is is getting passed to a file, while debugging this. Something what is get is not what you think you were getting.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
Yeah, I did the GETRESOURCENAME in a previous rule. I also used -T and -AUDIT (also quite helpful), and they basically all showed that the script was being called but the filename not being passed - that was until I added the SYMBOL(34)s to surround the full command line.

Anyway, it's working now so I'm happy :eek:)

Thanks for all your suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top