Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Calling external programs

Posted by smithce (smithce), 12 June 2006
Hi Graham

I have a number of perl scripts that call a configuration management package which in turn interogates it's own proprietary database.
This is fine except that now we are running tow versions of the external program and I need someway to interogate the path setting and substitute the for one version or the other.
Obviously, I can return the PATH variable from the %ENV hash but am a bit stumped on how I can strip out one setting and substitute the other depending upon which version I require.

The two executable path's are:
C:\Telelogic\SYNERGY CM 6.4\bin
and
F:\CMSYNERGY\BIN

Yes...the old version is a network install, the new one is a local install.

I realise this is a bit of a numpty question but it is Monday morning after all !!

Posted by admin (Graham Ellis), 12 June 2006
Silly question (because it's Monday evening  

Why not simply have your Perl script run the new version by giving the full path to it, and not bothering with the environment variable at all?   Or have I missed something?

Posted by smithce (smithce), 13 June 2006
Exactly....I did try that but because the second executable path has spaces in it it did not seem to work.

One of the things that I have struggled with since picking up Perl is quoting, backticks etc etc.

CM Synergy (The application) has a query line e.g.

open(CCM ,`C:\\Telelogic\\SYNERGY CM 6.4\\bin\\ccm` . "start -d $db_path -h $db_host -m -pw $db_passwd -n $db_user -r $role -q -nogui| ") ||
           die "ERR_004 : ccm start $db_path failed \n" ;

Because the later version of CM synergy has been installed to a path with spaces I tried the above using the join command to join the command line together. However, now it complains about the -d option.

Now, in my guestimation it's either not translating the command line properly or it's picking up the wrong version of the executable ?


Posted by admin (Graham Ellis), 13 June 2006
I think your Perl script can probably run something with spaces in the path name using something like ....

$result = `"C:\\Telelogic\\SYNERGY CM 6.4\\bin\\ccm" start -d etc etc`

The vital things are the double quotes to pass in the full path and program hame to the windows shell ...

Posted by smithce (smithce), 13 June 2006
Yes...with your help and reading through the perlop I see what I was doing wrong !!

Many thanks
Clive



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho