08-17-2011
Your are star, that's solved it. obviously i need more research on passing arguments !!
Many thanks again, superb...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a webpage that is in HTML and PHP. In PHP I have tried using exec, system, shell_exec and passthru functions to call an Expect Script file (temp.exp). This Expect file spawns a telnet session that uses "expect/send" commands to retrieve information from an environmental unit (not a normal... (0 Replies)
Discussion started by: CCUSmith
0 Replies
2. Shell Programming and Scripting
I call a EXPECT script from my perl script with machine IP and a FIle. The script logins to the machine and exports the value. The values to be exported or stored in a file.
I have close to 10 machines and I have created 10 files and pass the corresponding files in command line, Now I could like... (4 Replies)
Discussion started by: ramkriz
4 Replies
3. Shell Programming and Scripting
Hi all,
I have written a small expect script which should spawn a telnet session login and execute some commands.
#!/usr/bin/expect -f
spawn telnet $env(IP)
match_max 100000
expect "login:"
send -- "******\n"
expect -exact "Password:"
send -- "****\n"
expect "%"
Now I have got... (2 Replies)
Discussion started by: stinkefisch
2 Replies
4. Shell Programming and Scripting
I'm calling an expect script via a ksh script in cron and it is failing. The script runs fine if i run it manually. Does anyone know if it is an issue with compatibilty and if there is a way around it? (2 Replies)
Discussion started by: bhatia
2 Replies
5. Shell Programming and Scripting
Hi,
Please share you experience and way out on below error:-->
#!/bin/bash -xv
FILE=login.txt
+ FILE=login.txt
CONNECT=sshlogin.exp
+ CONNECT=sshlogin.exp
SERVERNAME=$1
+ SERVERNAME=192.168.12.1
MyServer=""
+ MyServer=
MyUser=""
+ MyUser=
MyPassword=""
+ MyPassword=
exec 3<&0
+... (6 Replies)
Discussion started by: manish_1678
6 Replies
6. Shell Programming and Scripting
Hi there,
I need some help regarding the execution of shell script from expect as the method I am trying is giving me error. I wrote an shell program which takes two arguments to telnet to a device and saves the output in a file. Following is the script.... (0 Replies)
Discussion started by: cyberparanoid
0 Replies
7. Shell Programming and Scripting
Hi all,
This is the first time i am using expect.
I am trying to call a function with in the shell script. The function will shh to a new server and will pass the password using expect and send. I need help in calling the fuction i am getting follaowing errors...
here the script
... (8 Replies)
Discussion started by: firestar
8 Replies
8. Programming
Hi,
Am very new to expect scripting..
Can You please suggest me how to call an expect script inside another expect script..
I tried with
spawn /usr/bin/ksh
send "expect main.exp\r"
expect $root_prompt
and
spawn /usr/bin/ksh
send "main.exp\r"
expect $root_prompt
Both... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies
9. Programming
I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues:
set REMOTE "/root/scripts/remote"
...
log_user 1
send_user "Executing remote script as $user...\n"
send_user "Command to execute is: $REMOTE... (1 Reply)
Discussion started by: brettski
1 Replies
10. Shell Programming and Scripting
password check in bash script calling on expect
Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all linux servers. most of them have the same... (1 Reply)
Discussion started by: 2legit2quit
1 Replies
LEARN ABOUT DEBIAN
dbix::dbstag::sqltemplate
DBIx::DBStag::SQLTemplate(3pm) User Contributed Perl Documentation DBIx::DBStag::SQLTemplate(3pm)
NAME
DBIx::DBStag::SQLTemplate - A Template for an SQL query
SYNOPSIS
# find template by name
$template = $dbh->find_template("mydb-personq");
# execute this template, filling in the 'name' attribute
$xml = $dbh->selectall_xml(-template=>$template,
-bind=>{name => "fred"});
DESCRIPTION
A template represents a canned query that can be parameterized.
Templates are collected in directories (in future it will be possible to store them in files or in the db itself).
To tell DBStag where your templates are, you should set:
setenv DBSTAG_TEMPLATE_DIRS "$HOME/mytemplates:/data/bioconf/templates"
Your templates should end with the suffix .stg, otherwise they will not be picked up
You can name templates any way you like, but the standard way is to use 2 or 3 fields
SCHEMA-OBJECT
or
SCHEMA-OBJECT-QUALIFIERS
(with underscores used within fields)
A template file should contain at minimum some SQL; for example:
Example template 1
SELECT
studio.*,
movie.*,
star.*
FROM
studio NATURAL JOIN
movie NATURAL JOIN
movie_to_star NATURAL JOIN
star
WHERE
[movie.genre = &genre&] [star.lastname = &lastname&]
USE NESTING (set(studio(movie(star))))
Thats all! However, there are ways to make your template more useful
Example template 2
:SELECT
studio.*,
movie.*,
star.*
:FROM
studio NATURAL JOIN
movie NATURAL JOIN
movie_to_star NATURAL JOIN
star
:WHERE
[movie.genre = &genre&] [star.lastname = &lastname&]
:USE NESTING (set(studio(movie(star))))
//
schema: movie
desc: query for fetching movies
By including : at the beginning it makes it easier for parsers to assemble SQL (this is not necessary for DBStag however)
After the // you can add tag: value data.
You should set schema: if you want the template to be available to users of a db that conforms to that schema
GETTING A TEMPLATE
The DBIx::DBStag object gives various methods for fetching templates by name, by database or by schema
VARIABLES
WHERE clause variables in the template look like this
&foo&
variables are bound at query time
my $set = $dbh->selectall_stag(-template=>$t,
-bind=>["bar"]);
or
my $set = $dbh->selectall_stag(-template=>$t,
-bind=>{foo=>"bar"});
If the former is chosen, variables are bound from the bind list as they are found
OPTIONAL BLOCKS
WHERE [ foo = &foo& ]
If foo is not bound then the part between the square brackets is left out
Multiple option blocks are ANDed together
An option block need not contain a variable - if it contains no &variable& name it is automatically ANDed
BINDING OPERATORS
The operator can be bound at query time too
WHERE [ foo => &foo& ]
Will become either
WHERE foo = ?
or
WHERE foo LIKE ?
or
WHERE foo IN (f0, f1, ..., fn)
Depending on whether foo contains the % character, or if foo is bound to an ARRAY
METHODS
name
Usage - $name = $template->name
Returns - str
Args -
every template has a name that (should) uniquely identify it
desc
Usage - $desc = $template->desc
Returns - str
Args -
templates have optional descriptions
get_varnames
Usage - $varnames = $template->get_varnames
Returns - listref of strs
Args -
Returns the names of all variable used in this template
WEBSITE
<http://stag.sourceforge.net>
AUTHOR
Chris Mungall <cjm@fruitfly.org>
COPYRIGHT
Copyright (c) 2003 Chris Mungall
This module is free software. You may distribute this module under the same terms as perl itself
perl v5.12.4 2010-02-01 DBIx::DBStag::SQLTemplate(3pm)