Sponsored Content
Top Forums Shell Programming and Scripting How To Run A For Loop In A Remsh? Post 302506130 by jim mcnamara on Friday 18th of March 2011 03:28:55 PM
Old 03-18-2011
This may work for you, I've done it in the past.

Enter the command line on your local box:
Code:
for i in 1 2 3 
do
   echo $i
done

ctrl/c to break the command (probably won't work locally anyway)
Next recall the command.
-for example in bash: ctrl-up arrow or ksh (with export EDITOR=vi) esc-k
You now have a line that looks like:
Code:
for i in 1 2 3 ^Jdo ^Jecho $i ^Jdone

scrape the screen, then paste the command string:
Code:
remsh host "for i in 1 2 3 ^Jdo ^Jecho $i ^Jdone"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remsh and run script

Help! I'm would like to log in su - within a script an contuine to run the commands within the script. Every time I log in as su - I have to exit for the rest of the script to run! e.g. #!/bin/ksh su - oracle ps -ef |grep som <--- doesn't excute command until I log out su oracle.... (1 Reply)
Discussion started by: bugggg
1 Replies

2. Shell Programming and Scripting

The loop does not run as expected

Hi folks, I have the following configuration file: DB_LAYER=NO ADMIN_LAYER=NO RTESUB_LAYER=NO DB_HOST_NAME=tornado ADMIN_HOST_NAME=tornado RTESUB_HOST_NAME=tornado RESPONSE_FILE_SR=/tmp/SR.rsp INSTALL_SR_1=/home/Upgrade_4.7.1/Utilities/Install_SR:Y... (8 Replies)
Discussion started by: nir_s
8 Replies

3. Shell Programming and Scripting

remsh newhost "for loop"

Hi, In ksh how can I execute something like this: remsh newhost "for i in 1 2 3 4 5 do echo file$i; cat file$i; done" I cannot pass the contrl J or enter in th above line which is required by the for loop. Thanks... (1 Reply)
Discussion started by: alantang
1 Replies

4. UNIX for Advanced & Expert Users

remsh inside of while loop

I have a space delimited file containing: hostname OracleSID connectstring I want to loop through the file and execute remsh to check the database processes. cat $filename | while read HOST SID CONNECT do { result=`remsh $HOST "ps -ef | grep pmon_${SID}$| grep -v grep"` if ........ (1 Reply)
Discussion started by: joettacm
1 Replies

5. Shell Programming and Scripting

How To Run AWK via Remsh?

Boy I hope someone can answer this question. I've been beating my head against the wall all day trying to come up with a solution. I have a carrot delimited file that looks like this: ANDERSON^678934^1974^BOB JONES^564564345^1954^ABRAHAM SMITH^47568465^1948^JON If I run this command: awk... (6 Replies)
Discussion started by: Korn0474
6 Replies

6. Shell Programming and Scripting

Is there a better way I could have run this loop. (For loop with two variables)

Sorry for such a dreadful title, but I'm not sure how to be more descriptive. I'm hoping some of the more gurutastic out there can take a look at a solution I came up with to a problem, and advice if there are better ways to have gone about it. To make a long story short around 20K pieces of... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

7. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

8. Shell Programming and Scripting

How to run it in the loop??

I have this code awk -F, ' { C5+=$5 C6+=$6 C7+=$7 C8+=$8 R=$5+$6+$7+$8 T+=R } { print $0,R } END { print... (7 Replies)
Discussion started by: nikhil jain
7 Replies

9. Shell Programming and Scripting

Run the for loop in parallel

I have the below code which runs on multiple databases , but this runs one-after-one. I will need this to run in parallel so that i could save a lot of time. Please help!!! Thanks in advance for Db in `cat /var/opt/oracle/oratab |egrep -v "ASM" |grep -v \# |cut -d\: -f1` do { export... (5 Replies)
Discussion started by: jjoy
5 Replies

10. Shell Programming and Scripting

Trying to run a basic for loop

OS : RHEL 6.1 Shell : Bash I had a similair post on this a few weeks back. But I didn't explain my requirements clearly then. Hence starting a new thread now. I have lots of files in /tmp/stage directory as show below. I want to loop through each files to run a command on each file. I... (8 Replies)
Discussion started by: kraljic
8 Replies
term::ansi::code::ctrl(n)					 Terminal control					 term::ansi::code::ctrl(n)

__________________________________________________________________________________________________________________________________________________

NAME
term::ansi::code::ctrl - ANSI control sequences SYNOPSIS
package require Tcl 8.4 package require term::ansi::code ?0.1? package require term::ansi::code::ctrl ?0.1.1? ::term::ansi::code::ctrl::names ::term::ansi::code::ctrl::import ?ns? ?arg...? ::term::ansi::code::ctrl::eeol ::term::ansi::code::ctrl::esol ::term::ansi::code::ctrl::el ::term::ansi::code::ctrl::ed ::term::ansi::code::ctrl::eu ::term::ansi::code::ctrl::es ::term::ansi::code::ctrl::sd ::term::ansi::code::ctrl::su ::term::ansi::code::ctrl::ch ::term::ansi::code::ctrl::sc ::term::ansi::code::ctrl::rc ::term::ansi::code::ctrl::sca ::term::ansi::code::ctrl::rca ::term::ansi::code::ctrl::st ::term::ansi::code::ctrl::ct ::term::ansi::code::ctrl::cat ::term::ansi::code::ctrl::qdc ::term::ansi::code::ctrl::qds ::term::ansi::code::ctrl::qcp ::term::ansi::code::ctrl::rd ::term::ansi::code::ctrl::elw ::term::ansi::code::ctrl::dlw ::term::ansi::code::ctrl::eg ::term::ansi::code::ctrl::lg ::term::ansi::code::ctrl::scs0 tag ::term::ansi::code::ctrl::scs1 tag ::term::ansi::code::ctrl::sda arg... ::term::ansi::code::ctrl::sda_fgblack ::term::ansi::code::ctrl::sda_fgred ::term::ansi::code::ctrl::sda_fggreen ::term::ansi::code::ctrl::sda_fgyellow ::term::ansi::code::ctrl::sda_fgblue ::term::ansi::code::ctrl::sda_fgmagenta ::term::ansi::code::ctrl::sda_fgcyan ::term::ansi::code::ctrl::sda_fgwhite ::term::ansi::code::ctrl::sda_fgdefault ::term::ansi::code::ctrl::sda_bgblack ::term::ansi::code::ctrl::sda_bgred ::term::ansi::code::ctrl::sda_bggreen ::term::ansi::code::ctrl::sda_bgyellow ::term::ansi::code::ctrl::sda_bgblue ::term::ansi::code::ctrl::sda_bgmagenta ::term::ansi::code::ctrl::sda_bgcyan ::term::ansi::code::ctrl::sda_bgwhite ::term::ansi::code::ctrl::sda_bgdefault ::term::ansi::code::ctrl::sda_bold ::term::ansi::code::ctrl::sda_dim ::term::ansi::code::ctrl::sda_italic ::term::ansi::code::ctrl::sda_underline ::term::ansi::code::ctrl::sda_blink ::term::ansi::code::ctrl::sda_revers ::term::ansi::code::ctrl::sda_hidden ::term::ansi::code::ctrl::sda_strike ::term::ansi::code::ctrl::sda_nobold ::term::ansi::code::ctrl::sda_noitalic ::term::ansi::code::ctrl::sda_nounderline ::term::ansi::code::ctrl::sda_noblink ::term::ansi::code::ctrl::sda_norevers ::term::ansi::code::ctrl::sda_nohidden ::term::ansi::code::ctrl::sda_nostrike ::term::ansi::code::ctrl::sda_reset ::term::ansi::send::fcp row col ::term::ansi::code::ctrl::cu ?n? ::term::ansi::code::ctrl::cd ?n? ::term::ansi::code::ctrl::cf ?n? ::term::ansi::code::ctrl::cb ?n? ::term::ansi::code::ctrl::ss ?s e? ::term::ansi::code::ctrl::skd code str ::term::ansi::code::ctrl::title str ::term::ansi::code::ctrl::gron ::term::ansi::code::ctrl::groff ::term::ansi::code::ctrl::tlc ::term::ansi::code::ctrl::trc ::term::ansi::code::ctrl::brc ::term::ansi::code::ctrl::blc ::term::ansi::code::ctrl::ltj ::term::ansi::code::ctrl::ttj ::term::ansi::code::ctrl::rtj ::term::ansi::code::ctrl::btj ::term::ansi::code::ctrl::fwj ::term::ansi::code::ctrl::hl ::term::ansi::code::ctrl::vl ::term::ansi::code::ctrl::groptim str ::term::ansi::code::ctrl::clear ::term::ansi::code::ctrl::init ::term::ansi::code::ctrl::showat row col text _________________________________________________________________ DESCRIPTION
This package provides symbolic names for the ANSI control sequences. For each sequence a single command is provided which returns the sequence as its result. None of the commands of this package write to a channel; that is handled by higher level packages, like term::ansi::send. API
INTROSPECTION ::term::ansi::code::ctrl::names This command is for introspection. It returns as its result a list containing the names of all attribute commands. ::term::ansi::code::ctrl::import ?ns? ?arg...? This command imports some or all attribute commands into the namespace ns. This is by default the namespace ctrl. Note that this is relative namespace name, placing the imported command into a child of the current namespace. By default all commands are imported, this can howver be restricted by listing the names of the wanted commands after the namespace argument. SEQUENCES ::term::ansi::code::ctrl::eeol Erase (to) End Of Line ::term::ansi::code::ctrl::esol Erase (to) Start Of Line ::term::ansi::code::ctrl::el Erase (current) Line ::term::ansi::code::ctrl::ed Erase Down (to bottom) ::term::ansi::code::ctrl::eu Erase Up (to top) ::term::ansi::code::ctrl::es Erase Screen ::term::ansi::code::ctrl::sd Scroll Down ::term::ansi::code::ctrl::su Scroll Up ::term::ansi::code::ctrl::ch Cursor Home ::term::ansi::code::ctrl::sc Save Cursor ::term::ansi::code::ctrl::rc Restore Cursor (Unsave) ::term::ansi::code::ctrl::sca Save Cursor + Attributes ::term::ansi::code::ctrl::rca Restore Cursor + Attributes ::term::ansi::code::ctrl::st Set Tab (@ current position) ::term::ansi::code::ctrl::ct Clear Tab (@ current position) ::term::ansi::code::ctrl::cat Clear All Tabs ::term::ansi::code::ctrl::qdc Query Device Code ::term::ansi::code::ctrl::qds Query Device Status ::term::ansi::code::ctrl::qcp Query Cursor Position ::term::ansi::code::ctrl::rd Reset Device ::term::ansi::code::ctrl::elw Enable Line Wrap ::term::ansi::code::ctrl::dlw Disable Line Wrap ::term::ansi::code::ctrl::eg Enter Graphics Mode ::term::ansi::code::ctrl::lg Exit Graphics Mode ::term::ansi::code::ctrl::scs0 tag Set default character set ::term::ansi::code::ctrl::scs1 tag Set alternate character set Select Character Set. Choose which character set is used for either default (scs0) or alternate font (scs1). This does not change whether default or alternate font are used, only their definition. The legal tags, and their meanings, are: A United Kingdom Set B ASCII Set 0 Special Graphics 1 Alternate Character ROM Standard Character Set 2 Alternate Character ROM Special Graphics ::term::ansi::code::ctrl::sda arg... Set Display Attributes. The arguments are the code sequences for the possible attributes, as provided by the package term::ansi::code::attr. For convenience this package also provides additional commands each setting a single specific attribute. ::term::ansi::code::ctrl::sda_fgblack Set text color to Black. ::term::ansi::code::ctrl::sda_fgred Set text color to Red. ::term::ansi::code::ctrl::sda_fggreen Set text color to Green. ::term::ansi::code::ctrl::sda_fgyellow Set text color to Yellow. ::term::ansi::code::ctrl::sda_fgblue Set text color to Blue. ::term::ansi::code::ctrl::sda_fgmagenta Set text color to Magenta. ::term::ansi::code::ctrl::sda_fgcyan Set text color to Cyan. ::term::ansi::code::ctrl::sda_fgwhite Set text color to White. ::term::ansi::code::ctrl::sda_fgdefault Set default text color (Black). ::term::ansi::code::ctrl::sda_bgblack Set background to Black. ::term::ansi::code::ctrl::sda_bgred Set background to Red. ::term::ansi::code::ctrl::sda_bggreen Set background to Green. ::term::ansi::code::ctrl::sda_bgyellow Set background to Yellow. ::term::ansi::code::ctrl::sda_bgblue Set background to Blue. ::term::ansi::code::ctrl::sda_bgmagenta Set background to Magenta. ::term::ansi::code::ctrl::sda_bgcyan Set background to Cyan. ::term::ansi::code::ctrl::sda_bgwhite Set background to White. ::term::ansi::code::ctrl::sda_bgdefault Set default background (Transparent). ::term::ansi::code::ctrl::sda_bold Bold on. ::term::ansi::code::ctrl::sda_dim Dim on. ::term::ansi::code::ctrl::sda_italic Italics on. ::term::ansi::code::ctrl::sda_underline Underscore on. ::term::ansi::code::ctrl::sda_blink Blink on. ::term::ansi::code::ctrl::sda_revers Reverse on. ::term::ansi::code::ctrl::sda_hidden Hidden on. ::term::ansi::code::ctrl::sda_strike Strike-through on. ::term::ansi::code::ctrl::sda_nobold Bold off. ::term::ansi::code::ctrl::sda_noitalic Italics off. ::term::ansi::code::ctrl::sda_nounderline Underscore off. ::term::ansi::code::ctrl::sda_noblink Blink off. ::term::ansi::code::ctrl::sda_norevers Reverse off. ::term::ansi::code::ctrl::sda_nohidden Hidden off. ::term::ansi::code::ctrl::sda_nostrike Strike-through off. ::term::ansi::code::ctrl::sda_reset Reset all attributes to their default values. ::term::ansi::send::fcp row col Force Cursor Position (aka Go To). ::term::ansi::code::ctrl::cu ?n? Cursor Up. n defaults to 1. ::term::ansi::code::ctrl::cd ?n? Cursor Down. n defaults to 1. ::term::ansi::code::ctrl::cf ?n? Cursor Forward. n defaults to 1. ::term::ansi::code::ctrl::cb ?n? Cursor Backward. n defaults to 1. ::term::ansi::code::ctrl::ss ?s e? Scroll Screen (entire display, or between rows start end, inclusive). ::term::ansi::code::ctrl::skd code str Set Key Definition. ::term::ansi::code::ctrl::title str Set the terminal title. ::term::ansi::code::ctrl::gron Switch to character/box graphics. I.e. switch to the alternate font. ::term::ansi::code::ctrl::groff Switch to regular characters. I.e. switch to the default font. ::term::ansi::code::ctrl::tlc Character graphics, Top Left Corner. ::term::ansi::code::ctrl::trc Character graphics, Top Right Corner. ::term::ansi::code::ctrl::brc Character graphics, Bottom Right Corner. ::term::ansi::code::ctrl::blc Character graphics, Bottom Left Corner. ::term::ansi::code::ctrl::ltj Character graphics, Left T Junction. ::term::ansi::code::ctrl::ttj Character graphics, Top T Junction. ::term::ansi::code::ctrl::rtj Character graphics, Right T Junction. ::term::ansi::code::ctrl::btj Character graphics, Bottom T Junction. ::term::ansi::code::ctrl::fwj Character graphics, Four-Way Junction. ::term::ansi::code::ctrl::hl Character graphics, Horizontal Line. ::term::ansi::code::ctrl::vl Character graphics, Vertical Line. ::term::ansi::code::ctrl::groptim str Optimize character graphics. The generator commands above create way to many superfluous commands shifting into and out of the graphics mode. This command removes all shifts which are not needed. To this end it also knows which characters will look the same in both modes, to handle strings created outside of this package. ::term::ansi::code::ctrl::clear Clear screen. In essence a sequence of CursorHome + EraseDown. ::term::ansi::code::ctrl::init Initialize default and alternate fonts to ASCII and box graphics. ::term::ansi::code::ctrl::showat row col text Format the block of text for display at the specified location. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category term of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
ansi, attribute control, color control, control, terminal CATEGORY
Terminal control COPYRIGHT
Copyright (c) 2006-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net> term 0.1 term::ansi::code::ctrl(n)
All times are GMT -4. The time now is 09:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy