Net/ssh exec builtin command (cd)

when using ssh.exec!(“ls -al”) everything is ok however, if i try to use
“cd /path/to” (a shell builtin command) i get back :
exec: 4: cd: not found

on the device a “which cd” returns nothing.

is there a workaround ?

From: Une Bévue [mailto:[email protected]]

when using ssh.exec!(“ls -al”) everything is ok however, if i

try to use

“cd /path/to” (a shell builtin command) i get back :

exec: 4: cd: not found

on the device a “which cd” returns nothing.

is there a workaround ?

show net/ssh version and code pls.

eg, i just run this,

Net::SSH.start( “10.2.10.1”, “botp:)”, :password=>“secret=)”) do
|session|
puts session.exec! “cd /etc; ls -la”
end

outputs=>
(irb):57: warning: parenthesize argument(s) for future version
total 1220
drwxr-xr-x 100 root root 8192 2008-06-25 19:40 .
drwxr-xr-x 30 root root 4096 2008-06-25 18:50 …
-rw-r–r-- 1 root root 2149 2006-04-07 16:16 adduser.conf
-rw-r–r-- 1 root root 44 2008-06-25 19:37 adjtime
-rw-r–r-- 1 root root 65 2006-04-28 18:52 aliases
-rw-r–r-- 1 root root 12288 2008-05-05 15:29 aliases.db
drwxr-xr-x 2 root root 8192 2008-06-25 18:53 alternatives

works, right?

kind regards -botp

Peña, Botp [email protected] wrote:

show net/ssh version and code pls.

net/ssh 2.0.3
net/scp 1.0.1

— ssh_exec_ls.rb -----------------------------------------------------
#! /usr/bin/env ruby

require ‘net/ssh’

result=""
options={
:config => false,
#:config => “/Users/yt/.ssh/ssh_config”,
:paranoid => false,
#:verbose => :debug,
:auth_methods => [“publickey”],
:user_known_hosts_file => “/Users/yt/.ssh/known_hosts”,
:keys => ["/Users/yt/.ssh/id_dsa"],
:passphrase => “A very vety long passphrase.”,
:port => 2222
}
Net::SSH.start(“169.254.0.2”, “root”, options) do |session|
result=session.exec!(“cd /mnt/fat;ls -Al”)
end

puts result
— /ssh_exec_ls.rb ----------------------------------------------------

eg, i just run this,

Net::SSH.start( “10.2.10.1”, “botp:)”, :password=>“secret=)”) do |session|
puts session.exec! “cd /etc; ls -la”
end

about the same except authentification by passphrase.

works, right?

i got :
$ ./ssh_exec_ls.rb
exec: 4: cd: not found

if, by command line, i log into the device :
$ ./ssh_connect.zsh open
Enter passphrase for /Users/yt/.ssh/id_dsa:
Identity added: /Users/yt/.ssh/id_dsa (/Users/yt/.ssh/id_dsa)
[…]
Last login: Sat Jul 26 08:57:20 UTC 2008

cd /mnt/fat

ls -Al

-rwxr-xr-x 1 root root 6148 Jul 23 10:04 .DS_Store
[…]
-rwxr-xr-x 1 root root 16384 Jul 19 07:52 x-loader.bin

which cd

notice “which cd” returns nothing, this is a builtin shell command.

for example on MacOS X :
$ which cd
cd: shell built-in command

i should mention the remote device is a handheld phone running linux
Kernel 2.4.x (QTopia over OMAP 730 from TI)

also, I’ve a lot of “SCP did not finish successfully” not repeatable.
those scp errors are only reported when using ruby (net/ssh + net/scp)
but not when using my zsh script.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs