Author Topic: simple question for you unix experts!  (Read 1885 times)

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
simple question for you unix experts!
« on: February 05, 2007, 09:57:34 AM »
okay.. here is what i am trying to do.  i would like unix to automatically log what i do via telnet to a router.
i sort of have this working - minus my invisibility feature :)

i type router1.exp , and it logs me into the router, and if i were to type at a blank prompt, the output would go to the file i specified

.exp logs in to the routers and send standard input back to the keyboard, so if i go router.exp>>log the output from the router goes to log.  can i use | or & to get this to work somehow!  there has to be something
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline console

  • Brobdingnagian Member
  • ***
  • Posts: 4518
  • "Man, this is the way to travel," said my attorney
    • View Profile
    • tastyspleen.net
  • Rated:
Re: simple question for you unix experts!
« Reply #1 on: February 05, 2007, 11:07:23 AM »
We can't know how unix works because it is incomprehensible.

 :evilgrin:  j/k


man tee

    tee - read from standard input and write to standard output and files


Hope this helps,

:mrgreen:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: simple question for you unix experts!
« Reply #2 on: February 05, 2007, 11:09:32 AM »
awesome, i got it working with expect:

set lfile argv
log_file -noappend /var/log/$lfile
expect "CISCO2611SCHDY01#"
interact
log_file

so if i wanna log into a router, and have it logged. i type routerX date , and it logs me and creates a log named as you choose

but i'm trying to learn unix better, and tee sounds very useful

but i might need tee for stuff i don't have scripts for !

i don't think tee, pipes, or redirect will work. looks like i have to mess with stdout. we will see how much community college paid off, i took for c classes there!

# redirect stdout to a disk file
    import sys
    saveout = sys.stdout
    outfile = open('output.txt', 'w')
    sys.stdout = outfile

    # output stuff
    print 'hello world'

    # restore stdout
    outfile.flush()
    outfile.close()
    sys.stdout = saveout:
« Last Edit: February 05, 2007, 12:05:35 PM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline DEMOn

  • Full Member
  • ***
  • Posts: 141
    • View Profile
  • Rated:
Re: simple question for you unix experts!
« Reply #3 on: February 08, 2007, 07:07:34 PM »
if you are using system V based (like Solaris), you should be able to type script <filename>, then everything you type gets re-directed to that file.
been awhile since I wrote an expect script....
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: simple question for you unix experts!
« Reply #4 on: February 09, 2007, 09:16:30 AM »
Quote from: demon
if you are using system V based (like Solaris), you should be able to type script <filename>, then everything you type gets re-directed to that file.
been awhile since I wrote an expect script....

what were you using expect for, servers or network stuff?  i love expect it makes my life so much easier : ) . if i type script <file>  the commands i type got to a file - which would be good - but i also need output to go to the file, as well as the screen.  i do have "automatic" logging working now, it's really just typing script <logfilename>  (the script logs from an expect command creating the filename from the argument).

what i want to do is have it create the log file based on the time and the device i'm logging into - i'm suprised there isn't an expect script out there for this (if there is i haven't found it).  i don't think any of these scripts are to portable, obviously because their unique to each device, but i would like to have a template script, that automatically logs via hostname & time.

that would be really nice, because if you are going to log into a router more than once, just create an expect script by altering one or two lines, then when you change stuff, it will be logged - you could also automatic config backups this way.  i guess you could use tftp or ciscoworks or something, but automatic login, and logging is nice via expect
« Last Edit: February 09, 2007, 09:20:21 AM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

 

El Box de Shoutamente

Last 10 Shouts:

 

-Unh0ly-

May 22, 2025, 05:45:28 PM
 

Yotematoi

May 17, 2025, 08:33:15 AM
Yo desde el año 2007 me enfermé de Q2, es incurable  
Morir y revivir es costumbre, lástima q el QT estaba bueno
 

ImperiusDamian

May 12, 2025, 01:45:35 AM
Quake II is not 27 years old. I refuse to accept THAT much time has gone by.
 

|iR|Focalor

May 11, 2025, 02:33:39 PM
 

-Unh0ly-

May 03, 2025, 08:02:46 AM
198.179.6.200:30634
 

Yotematoi

May 02, 2025, 10:27:47 AM
Note for Player-4109 "Remember, the Guinness Book of Records does not include cowards who shot at someone by treachery." :D
 

|iR|Focalor

April 02, 2025, 02:47:07 AM
 

Yotematoi

February 14, 2025, 12:41:48 PM
 :-*

Show 50 latest
Welcome, Guest. Please login or register.
May 24, 2025, 11:26:23 PM

Login with username, password and session length