Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ssh -R 2222:127.0.0.1:22 user@linuxmachine control-script
- ssh -p 2222 user@localhost something.cmd
- watch -n 5 ~/checker.bash
- #!/bin/bash
- if [ -f myscript.bash ]; then
- sh ~/myscript.bash
- else
- echo 'checking...'
- fi
- #!/bin/bash
- /cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/devenv.exe
- rm myscript.bash
- #!/usr/bin/expect
- set timeout 10
- log_user 1
- spawn bash --login
- expect -re {.*$} ;# Assumes a dollar sign in your prompt on local box
- send "ssh remoteuser@your_remote_linux_boxr"
- expect "*word:*"
- send "REMOTE_PASSWORDr" ;# Bad security practice!! For illustration purposes only.
- expect -re {rn.*$} ;# Assumes a dollar sign in your prompt on your remote box
- puts "Connected to remote system"
- set i 0
- while {$i < 5} { ;# For now, we just loop 5 times. You might loop forever...
- send "ls ~/TasksSpoolDir | wc -lr";
- expect -re "rn([0-9]+)r"
- set taskcount $expect_out(1,string)
- sleep 1
- if { $taskcount } {
- # Inspect remote job files from spool directory, for example, to determine what you want to do locally
- send "r~ 32" ;# Send ~CTRL-Z to ssh
- expect "Stopped"
- send "pwd; ls; echo Do local tasks now. Remove remote job files from spool directory...r"
- sleep 1
- send "fgr" ;# Resume ssh.
- sleep 1
- send "rr"
- expect -re {rn.*$} ;# Assumes a dollar sign in your prompt on your remote box
- }
- incr i
- sleep 1; # Sleep however long between checks for new work from spool directory
- }
- send "exitr"
- expect -re {.*closed}
- puts "Connection to remote host closed..."
- send "exitr"
- expect "*"
- puts "Local bash process closed..."
- wait
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement