Expect Terminal Macros


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect Terminal Macros
# 1  
Old 02-25-2008
Expect Terminal Macros

Hey people!

I just started out working at an ISP as tech support and thought that I should ease the work load by scripting some small macros.

I create different commands with Alias through .bashrc which are all directed to the same script file. Here I planned on using Expect to run different input macros. Problem i came across though is that I can't set a varible to the command i ran to execute the script file.

So i .bashrc i have written
alias command2="~/scirpt.file"

and in script.file i have made the different rules for each command.

An easy solution to the problem would be to create one script file for each command, but that isn't as neat, easpesially not if I want to distribute the script to my collegues.

What i need in script.file is a line that sets a variable to the command that I have inputed so i can create an if-statement for which action that should be taken.

so if i have the terminal like this.

ghettofish@server:~$ command2

then i should go to script.file and have a statement that does the following.

set input_command [code to retrive command that executed the script.file]

Then later i could create an if-statement that would be something like
if ($input_command == "command2") blah blah

Anyone got any ideas?
Hope someone could help me out with this.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Macros how-to?

Hi, all I just came to new system with RH, and it has alot of macros I was told to use, but I can't find how to open it for display or for edit, can you help me please, is it all about make/makefile? let say I have macro <trx> like this, that does a lot of things: >$ trx ... creating new... (1 Reply)
Discussion started by: trento17
1 Replies

2. Programming

help with atoi and macros in C

I have a PORT_NUM macro (10 digits long number) in a server file, if i do htons(PORT_NUM) i get warning: this decimal constant is unsigned only in ISO C90 warning: large integer implicitly truncated to unsigned type whats wrong with this? (2 Replies)
Discussion started by: omega666
2 Replies

3. Shell Programming and Scripting

How can I scroll the terminal output with Expect

Hi, I'm trying to come up with a simple expect script that allows me to login to a system and run a single command ... something like this: #!/usr/bin/expect -f # let's set some variables #set password set ipaddr set ponumber set hostname set timeout -1 # let's now connect to the... (0 Replies)
Discussion started by: danielsf
0 Replies

4. UNIX for Advanced & Expert Users

Using Macros in sftp command

Hi, I've some existing scripts wherein am using ftp + .netrc. I've defined my macros in .netrc file. I want to switch to sftp now but it seems it doesn't support macros and .netrc and it gives "command invalid" error. Is there any other alternative? Note: I don't want help for... (1 Reply)
Discussion started by: ps51517
1 Replies

5. Linux

What are the meaning of these macros..

Masters, I am trying to learn the serial mouse driver for linux kernel. On the kernel source tree I find out these macros and I am unable to find out the meaning of these macros. Please anyone help me to understand these. These macros are defined in linux/serio.h... (2 Replies)
Discussion started by: iamjayanth
2 Replies

6. UNIX for Dummies Questions & Answers

MAKE and its macros and variables

I want to build a Makefile that simply takes a template file and modifies it (sed or perl, probably) before installing the result in the right place - my problem is creating the variable for substitution... So I have SYSTEM = SYS1 SYS2 SYS1_CHANNELS = CHANNEL1 CHANNEL2 CHANNEL4... (1 Reply)
Discussion started by: JerryHone
1 Replies

7. Programming

One last question about capability macros

This might be poorly worded. In the header file, I have #ifdef LOCK_FCNTL #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif #define LOCK(file) setlock(fileno(file), F_WRLCK); #define UNLOCK(file) setlock(fileno(file), F_UNLCK); #endif /* LOCK_FCNTL */ #ifdef LOCK_FLOCK #ifdef... (1 Reply)
Discussion started by: frequency8
1 Replies

8. Programming

How do capability macros get named?

The following is taken from some production code: #ifdef LOCK_LOCKF #ifdef HAVE_SYS_FILE_H #include <sys/lockf.h> #endif #ifdef HAVE_SYS_FILE_H #include <sys/file.h> #endif #define LOCK(file) fseek(file, 0L, 0), lockf(file, 1, 0L) #define UNLOCK(file) fseek(file, 0L, 0),... (2 Replies)
Discussion started by: frequency8
2 Replies

9. UNIX for Dummies Questions & Answers

saving macros for VIM

The question is , as the topic says, how does one save macros for VIM in the .vimrc. I had a look on web and it gave all this ****** about how to build turing machines in vim code or something but i just want to store a macro to like : if(){ } I know how to do it IN vim but .vimrc??????!?!?!... (3 Replies)
Discussion started by: yngwie
3 Replies

10. UNIX for Dummies Questions & Answers

troff macros

Hi, I'm going write a small handbook. The typesetting software I'm going to use is troff. There are -ms -me -mm macros for troff. Which one is the most suitable? Thanks! -Tony (2 Replies)
Discussion started by: tonyt
2 Replies
Login or Register to Ask a Question
TERMINAL(1)							       Xfce							       TERMINAL(1)

NAME
Terminal - A Terminal emulator for X SYNOPSIS
Terminal [OPTION...] DESCRIPTION
Terminal is what is known as an X terminal emulator, often referred to as terminal or shell. It provides an equivalent to the old-fashioned text screen on your desktop, but one which can easily share the screen with other graphical applications. Windows users may already be familiar with the MS-DOS Prompt utility, which has the analogous function of offering a DOS command-line under Windows, though one should note that the UNIX CLI offer far more power and ease of use than does DOS. Terminal emulates the xterm application developed by the X Consortium. In turn, the xterm application emulates the DEC VT102 terminal and also supports the DEC VT220 escape sequences. An escape sequence is a series of characters that start with the Esc character. Terminal accepts all of the escape sequences that the VT102 and VT220 terminals use for functions such as to position the cursor and to clear the screen. OPTIONS
Option Summary Here is a summary of all the options, grouped by type. Explanations are in the following sections. General Options -h, --help; -V, --version; --disable-server; --default-display=display; --default-working-directory=directory Window or Tab Separators --tab; --window Tab Options -x, --execute; -e, --command=command; --working-directory=directory; -T, --title=title; -H, --hold Window Options --display=display; --geometry=geometry; --role=role; --startup-id=string; -I, --icon=icon; --fullscreen; --maximize; --show-menubar, --hide-menubar; --show-borders, --hide-borders; --show-toolbars, --hide-toolbars General Options -h, --help List the various command line options supported by Terminal and exit -V, --version Display version information and exit --disable-server Do not register with the D-BUS session message bus --default-display=display Default X display to use. --default-working-directory=directory Set directory as the default working directory for the terminal Window or Tab Separators --tab Open a new tab in the last-specified window; more than one of these options can be provided. --window Open a new window containing one tab; more than one of these options can be provided. Tab Options -x, --execute Execute the remainder of the command line inside the terminal -e, --command=command Execute command inside the terminal --working-directory=directory Set directory as the working directory for the terminal -T, --title=title Set title as the initial window title for the terminal -H, --hold Causes the terminal to be kept around after the child command has terminated Window Options --display=display X display to use for the last- specified window. --geometry=geometry Sets the geometry of the last-specified window to geometry. Read X(7) for more information on how to specify window geometries. --role=role Sets the window role of the last-specified window to role. Applies to only one window and can be specified once for each window you create from the command line. It is mostly used for session management inside Terminal --startup-id=string Specifies the startup notification id for the last-specified window. Used internally to forward the startup notification id when using the D-BUS service. -I, --icon=icon Set the terminal's icon as an icon name or filename. --fullscreen Set the last-specified window into fullscreen mode; applies to only one window; can be specified once for each window you create from the command line. --maximize Set the last-specified window into maximized mode; applies to only one window; can be specified once for each window you create from the command line. --show-menubar Turn on the menubar for the last-specified window. Can be specified once for each window you create from the command line. --hide-menubar Turn off the menubar for the last-specified window. Can be specified once for each window you create from the command line. --show-borders Turn on the window decorations for the last-specified window. Applies to only one window. Can be specified once for each window you create from the command line. --hide-borders Turn off the window decorations for the last-specified window. Applies to only one window. Can be specified once for each window you create from the command line. --show-toolbars Turn on the toolbars for the last-specified window. Applies to only one window. Can be specified once for each window you create from the command line. --hide-toolbars Turn off the toolbars for the last-specified window. Applies to only one window. Can be specified once for each window you create from the command line. EXAMPLES
Terminal --geometry 80x40 --command mutt --tab --command mc Opens a new terminal window with a geometry of 80 columns and 40 rows and two tabs in it, where the first tab runs mutt and the second tab runs mc. ENVIRONMENT
Terminal uses the Basedir Specification as defined on Freedesktop.org[1] to locate its data and configuration files. This means that file locations will be specified as a path relative to the directories described in the specification. ${XDG_CONFIG_HOME} The first base directory to look for configuration files. By default this is set to ~/.config/. ${XDG_CONFIG_DIRS} A colon separated list of base directories that contain configuration data. By default the application will look in ${sysconfdir}/xdg/. The value of ${sysconfdir} depends on how the program was build and will often be /etc/ for binary packages. ${XDG_DATA_HOME} The root for all user-specific data files. By default this is set to ~/.local/share/. ${XDG_DATA_DIRS} A set of preference ordered base directories relative to which data files should be searched in addition to the ${XDG_DATA_HOME} base directory. The directories should be separated with a colon. FILES
${XDG_CONFIG_DIRS}/Terminal/terminalrc This is the location of the configuration file that includes the preferences which control the look and feel of Terminal. ${XDG_DATA_DIRS}/Terminal/Terminal-toolbars.ui This file includes the user interface definition for the toolbars. If you customize the toolbars using the graphical toolbars editor, Terminal will store the new toolbars layout in the file ${XDG_DATA_HOME}/Terminal/Terminal-toolbars.ui. SEE ALSO
bash(1), X(7) AUTHORS
Nick Schermer <nick@xfce.org> Developer Benedikt Meurer <benny@xfce.org> Software developer, os-cillation, System development, Developer NOTES
1. Freedesktop.org http://freedesktop.org/ Terminal 0.4.4 02/01/2010 TERMINAL(1)