FreeBSD script in win ssh clients in one line?

Please, help!

I use plink.exe in windowsXP i wont it exec my script but this script asks a password and it does not work

befor i did
Code:
chmod +rx add1.sh

in file.bat i have
Code:
plink.exe -ssh 10.10.30.72 -l root -pw 1234 /usr/local/etc/add1.sh
pause

script
Code:
#!/bin/sh
mount_msdosfs /dev/da0s1 /mnt/usb
geli attach -k /mnt/usb/ad4s3d.key /dev/ad4s3d
mount /dev/ad4s3d.eli /usr/data/hdd12
df -h

d0390d663799.bmp


command geli attach asks for password but i dont see it in the window

in PUTTY ssh terminal my script works, but theres nou way by one click start putty with command Ж"((((((
 
3.7.3.6 -m: read a remote command or script from a file

The -m option performs a similar function to the "Remote command" box in the SSH panel of the PuTTY configuration box (see section 4.17.1). However, the -m option expects to be given a file name, and it will read a command from that file. On most Unix systems, you can even put multiple lines in this file and execute more than one command in sequence, or a whole shell script.

This option is not available in the file transfer tools PSCP and PSFTP.
http://the.earth.li/~sgtatham/putty/0.53/htmldoc/Chapter3.html#3.7.1


In any case:
1) you probably cannot ssh in as root unless you have enabled it
2) your password is useless.
3) certificate-based logins
 
I used putty but it dont work too

Code:
putty.exe root@10.10.30.72 -m 2.txt

this command

Code:
geli attach -k /mnt/usb/ad4s3d.key /dev/ad4s3d
does not ask the password

Code:
Using username "root".
Using keyboard-interactive authentication.
Password:
geli: Cannot read passphrase: Inappropriate ioctl for device.
                                                             mount: /dev/ad4s3d.eli : No such file or directory

but if i type this commnad in putty (started from icon) it works!
 
You can't script something interactive. If you want to script things like that you will have to use something like lang/p5-Expect.
 
You can try this in your add1.sh script

Code:
#!/bin/sh
mount_msdosfs /dev/da0s1 /mnt/usb
echo yourpasswd | geli attach -k /mnt/usb/ad4s3d.key /dev/ad4s3d
mount /dev/ad4s3d.eli /usr/data/hdd12
df -h

But it is not secure :\
 
Very happy right now!

but

1. this Expect lang is evil
- It needs whole big string just to input "any string"

2. this book Exploring Expect is evil (but good even I with my poor english could understend it)
- only on page 111 i find that realy needed

3. you are evil
- why you did no say too me that i only need construction like this
Code:
#!/usr/local/bin/expect --

puts "Change password input user name:\n"
expect -re "(.*)\n" {
   set name $expect_out(1,string)
}
puts "input $name password:\n"   ;# smile hides  ": \ n" without space
expect -re "(.*)\n" {
   set password $expect_out(1,string)
}

spawn passwd $name
expect "New Password:"
send "$password\r"
expect "Retype New Password:"
send "$password\r"
expect eof

4. vi is evil
- why he does one step behind than editing or deleting something

5. Wather is evil
- unsuported warm

I write this script (seen on string 3 higer) it woks, strange output but it works

in windows
Code:
@echo off
plink.exe -t -ssh 192.168.1.100 -l root -pw qwertty /usr/local/www/expect/6f
pause

Code:
Change password input user name:

u1
input u1 password:

12
spawn passwd u1
Changing local password for u1
New Password:
Retype New Password:

Uf i fink now i can write script for geom_eli to mount partition from windows exe file in one click (and too pass inputs of couse) on putty session

Thank you all ....brbrbr realy exousted all day finding solution!
 
Thank you ok!

I just found that all works without Expect if starts plink with "-t" Ж"))))))))))))
 
Back
Top