Solved

TCL variable use in wscp

Posted on 2002-06-10
5
219 Views
Last Modified: 2010-08-05
I'm trying to use the lsearch functionality of TCL, and I can not understand why this variable will not evaluate to its value.  Any ideas?

set ds_mdo "/JDBCDriver:Sample DB Driver/DataSource:"
append $ds_mdo $my_datasource
append $ds_mdo "/"

# check to see if my_datasource is installed
if {[lsearch [DataSource list] {$ds_mdo}] > -1}
{
     puts 'found datasource'
}
else
{
     puts 'did not find'
}
0
Comment
Question by:nixj14
  • 3
  • 2
5 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7067731
what does
   [DataSource list]
return?
0
 
LVL 1

Author Comment

by:nixj14
ID: 7067777
Alright, I've jumbled things around a little.  Now I have the following:
__________________________
set ds_mdo "mdo_30_merant"

# check to see if the MDO DataSource is already installed
if ([lsearch -regexp [DataSource list] "/JDBCDriver:Sample DB Driver/DataSource:$ds_mdo/"]>-1)
{
     puts 'found datasource'
}
else
{
     puts 'did not find'
}
__________________________
and this returns:
wrong # args: no script following "(-1>-1)" argument

DataSource List returns nothing because there is no datasources, which is fine.  What is funny is that my above script works when I'm in wscp, but not when I call wscp -f and include the text above in a file.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 7067911
# did you mean?
if {[lsearch -regexp [DataSource list] "/JDBCDriver:Sample DB Driver/DataSource:$ds_mdo/"]>-1} {
0
 
LVL 1

Author Comment

by:nixj14
ID: 7067949
Did I mention that I hate TCL??  I tried a close variation to that with the opening body bracket on the next line and I get an error message.  I was unable to find no documentation on grouping syntax with loops and conditionals.  I appreciate your help.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7068023
hate==love
:-))

It's like any language: you have to live with dragons

f.e. look at perl:
   $x=~string;   $y+=2;
   $x= ~string;  $y+ =2;
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

11 Experts available now in Live!

Get 1:1 Help Now