473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to change directory on Windows server using ssh connection

I use ssh password-less connection to connect to a Windows server from a Linux server. The connection is made to the E:\FTP working directory. I did a dir to list the file in the working directory. I had no output. I need to change directory to E:\pilot\dev_test directory.
I tried to use chdir(). It did not work. Followings are the code. Can anyone please help?
Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl
  2. use Net::SSH::Perl;
  3. use Net::SCP::Expect;
  4. my $remote_host = "remote_Windows_server.com";
  5. my $user = "aacesrdev";
  6. my $ssh = Net::SSH::Perl->new($remote_host, debug => 1, identity_files =>["/home/aacesrdev/.ssh/id_rsa"], protocol=>'2,1');
  7. $ssh->login($user);
  8. my $cmd = "dir";
  9. my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
  10. print "stderr= $stderr\n";
  11. print "stdout= $stdout\n";
  12. print "exit = $exit\n";
  13. my($stdout, $stderr, $exit) = $ssh->cmd(chdir("E:\pilot\dev_test"));
  14. print "stderr= $stderr\n";
  15. print "stdout= $stdout\n";
  16. print "exit = $exit\n";
  17.  
The outputs are as below:
stderr=
stdout=
exit = 8772
stderr=
stdout=
exit = 8772
Dec 18 '11 #1
5 3526
I use ssh connection to connect to a Windows server from a Linux server. The connection is made to the E:\FTP working directory. I need to change directory to E:\pilot\dev_test directory. I run the code as below. I had error on the windows server: "[057] RSSHD 7.00: .\sshd.cpp:WindowsSessionServer::HandleProcessExit (8052) Session server 294: Executing command in working directory 'E:\FTP' failed: Child process could not be created." Can anyone please help?

Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl
  2. use Net::SSH::Perl;
  3. use Net::SCP::Expect;
  4. my $remote_host = "remote_Windows_server.com";
  5. my $user = "aacesrdev";
  6. my $ssh = Net::SSH::Perl->new($remote_host, debug => 1, identity_files =>["/home/aacesrdev/.ssh/id_rsa"], protocol=>'2,1');
  7. $ssh->login($user);
  8. my($stdout, $stderr, $exit) = $ssh->cmd(chdir("E:\pilot\dev_test"));
  9.  
Dec 19 '11 #2
numberwhun
3,509 Expert Mod 2GB
Did you mean to have the line commented out that would create the new ssh object?

Regards,

Jeff
Dec 20 '11 #3
Sorry. That is my mistake. That line should not be commented out. I played around with different ssh connections. I forgot to remove the comment sign when I posted my questions.

Thanks,

Randy
Dec 20 '11 #4
RonB
589 Expert Mod 512MB
Try using single quotes in the chdir command instead of the double quotes.

Or, use forward slashes instead of back slashes.
Dec 20 '11 #5
RonB, The windows server I want to test the Perl code is down during the holidays. I will try what you suggested as soon as the server is up. thanks,
Dec 26 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: David Mitchell | last post by:
Hello group, I'm trying to create a TCP server using Python, and I want it to run under Windows as a service. Now, I'm fine with building the TCP server using Python - done it lots of times,...
0
by: newmem | last post by:
Hi We have web app running successfully on a windows 2000 server. Certain Admin pages have the authentication turned on and contains an admin web.config file which lists the user/groups in the...
2
by: RyoSaeba | last post by:
Hello, I have a problem with the session state set to Sql Server (AspNet 1.1, Windows Server 2003 on an Application Center cluster, Sql Server 2000 on another server). Sometimes, when many user...
4
by: shashank kadge | last post by:
hi all, i am trying to get local admin users and groups on a windows server. here is the C# code that i am using...
4
by: roblenator | last post by:
I am trying to access files on a remote windows server using the following code; my $node = 'server5'; opendir(DIR, '\\$node\C$\Servers') or warn "open failed. reason: $!"; I get an error;...
5
by: tjaink | last post by:
Hi I have a vc++ dll and its stored in Windows directory. I am using OS Windows 2003 server. And i am using ASP Legacy application migrated from NT to Windows 2003 server. Now there is no problem...
2
by: Awanka | last post by:
I have a windows Server 2003 machine, and need to make a connection to another Window Server 2003 machine, and copy over some files to a certain directory. In Unix I can just do this using ftp. Can...
0
JamieHowarth0
by: JamieHowarth0 | last post by:
Hi guys, Up until 3 weeks ago I was running a Microsoft Windows Server 2003 R2 Enterprise Edition Beta from home on an ADSL connection with dynamic IP absolutely fine - until the beta decided to...
2
blyxx86
by: blyxx86 | last post by:
Hey Everyone, I'm currently trying to recover from a server breach (when I was put in charge of the server there was no AV and no firewall for about 4 months before). It appears that the server has...
0
by: wassimdaccache | last post by:
Dear friends I am sharing a connection on windows server 2003 sp2 64 bit. I would make some policies for the users that are using this connection. I need some users to don't use the internet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.