Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]12691[/thread]

SCP im Systembefehl

Leser: 1


<< >> 10 Einträge, 1 Seite
Aendrew
 2008-10-29 12:04
#115814 #115814
User since
2008-10-29
12 Artikel
BenutzerIn
[default_avatar]
Hallo zusammen,

mein 'Problemkind' ist ein kleines Stück Perlcode:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
my $befehl = "C:\putty\pscp.exe -i \"C:\mykey.ppk\" -v -batch \"testuser\@192.168.3.24:/home/otheruser/information.txt\" \"D:\import\" 1>> D:\\import\\log.txt 2>>&1";
if(system($befehl))
{
  print "Datei <information.txt> konnte nicht übertragen werden! -\n";
  system("C:\putty\plink.exe -ssh -batch -i \"C:\mykey.ppk\" testuser\@192.168.3.24 \"mv /home/otheruser/information.txt /home/otheruser/ERR_information.txt\"");
}
else
{
system("C:\putty\plink.exe -ssh -batch -i \"C:\mykey.ppk\" testuser\@192.168.3.24 \"rm /home/otheruser/information.txt\"");
}



Auf dem Server 192.168.3.24 stelle ich in der Datei /home/otheruser/information.txt immer wieder Informationen zur Verfügung.

Was damit passieren soll ist klar... (abholen und löschen wenn erfolgreich, ansonsten verschieben)
Es funktioniert auch, naja, leider nur manchmal...

Immer wieder bleiben Dateien liegen. (Die heißen dann ERR_information.txt)

Aus diesem Grund hab ich das SCP logging (-v) aktiviert...
In dem Log stehen aber nur die erfolgreichen Übertragungen (failed, error, network, refused etc. sind nicht enthalten)


Kann mir jemand von euch sagen woran das liegen könnte, bzw. was ich hier ändern muss/sollte?

Danke für Eure Hilfe.

Gruß
Aendrew
Gast Gast
 2008-10-29 19:33
#115831 #115831
"\p" oder "\m" versteht perl nicht für ihn ist das einfch "p" oder "m"
Wenn du Doublequotes benutzen willst musst du "\" entwerten so: "\\" oder du nimmst Singlequotes:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
my $befehl = 'C:\putty\pscp.exe -i "C:\mykey.ppk" -v -batch "testuser\@192.168.3.24:/home/otheruser/information.txt" "D:\import" 1>> D:\\import\\log.txt 2>>&1';
if(system($befehl))
{
  print "Datei <information.txt> konnte nicht übertragen werden! -\n";
  system('C:\putty\plink.exe -ssh -batch -i "C:\mykey.ppk" testuser\@192.168.3.24 "mv /home/otheruser/information.txt /home/otheruser/ERR_information.txt"');
}
else
{
  system('C:\putty\plink.exe -ssh -batch -i "C:\mykey.ppk" testuser\@192.168.3.24 "rm /home/otheruser/information.txt"');
}
Gast Gast
 2008-10-29 19:55
#115832 #115832
Meinst du echt, dass das das Problem ist?

Er schreibt ja, dass der Befehl sonst ja funktioniert


Evtl. ist der Server nicht erreichbar oder die Rechte stimmen nicht
Gast Gast
 2008-10-29 21:09
#115835 #115835
Zumindest ist das ein Problem das mir aufgefallen ist.
kannst ja mal testen:
Code (perl): (dl )
system("echo \"c:\pfad\zur\datei.txt\"");

ich bin mir sicher dass dabei so was raus kommt:
Code: (dl )
c:pfadzurdatei.txt
renee
 2008-10-30 09:33
#115854 #115854
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Die System-Befehle stehen in Single-Quotes, das mit den \ dürfte also nicht das Problem sein.

@Aendrew: Warum nimmst Du nicht CPAN:Net::SCP?
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Aendrew
 2008-10-30 10:56
#115858 #115858
User since
2008-10-29
12 Artikel
BenutzerIn
[default_avatar]
renee+2008-10-30 08:33:14--
Die System-Befehle stehen in Single-Quotes, das mit den \ dürfte also nicht das Problem sein.

@Aendrew: Warum nimmst Du nicht CPAN:Net::SCP?



Hallo renee,

nein, mein Befehl steht nicht in Single-Quotes.
Ich hab das jetzt mal angepasst und werde das überwachen.


Der Grund warum ich nicht das Modul CPAN:Net::SCP verwende liegt darin, dass ich auf dem Server keine Software installieren darf. (plink und pscp hab ich nur kopiert)


Komisch an der Sache finde ich nur, dass es teilweise funktioniert...
Wenn es überhaupt nicht funktionieren würde ok, aber so....


Wie gesagt, ich hab das jetzt mal geändert und werde euch in kürze mehr sagen können...


Gruß
Aendrew
renee
 2008-10-30 11:03
#115859 #115859
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Aendrew+2008-10-30 09:56:19--
Hallo renee,

nein, mein Befehl steht nicht in Single-Quotes.

Ups, bin im Posting verrutscht. Sorry!
Quote
Der Grund warum ich nicht das Modul CPAN:Net::SCP verwende liegt darin, dass ich auf dem Server keine Software installieren darf. (plink und pscp hab ich nur kopiert)
Aber eigene Perl-Module darfst Du dort installieren? Manchmal verstehe ich Unternehmen nicht *kopfschüttel*
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Aendrew
 2008-10-30 11:54
#115860 #115860
User since
2008-10-29
12 Artikel
BenutzerIn
[default_avatar]
Hallo renee,

ich versteh es auch nicht immer...


Leider hat der Versuch mit den Singel-Quotes nichts gebracht...

Einige Dateien werden weiterhin umbenannt.


Hast du vielleicht noch eine Idee?

Eine kleine Ergänzung muss ich noch geben:
Das Script wird parallen mit verschiedenen Dateinamen gestartet (information.txt und information2.txt)

Jetzt steht aber endlich mal was in der Log-Datei
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Looking up host "192.168.3.24"
Connecting to 192.168.3.24 port 22
Server version: SSH-2.0-OpenSSH_4.2
We claim version: SSH-2.0-PuTTY_Release_0.60
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-rsa 1024 80:c5:8f:44:74:72:1c:8c:7b:b5:72:6f:f7:35:87:b9
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Reading private key file "C:\mykey.ppk"
Using username "rrdexport".
Offered public key
Offer of public key accepted
Authenticating with public key "dsa-key"
Access granted
Opened channel for session
Started a shell/command
information.txt | 32 kB | 32.0 kB/s | ETA: 00:00:07 | 12%
information.txt | 260 kB | 260.1 kB/s | ETA: 00:00:00 | 100%
Using SFTP
Connected to 192.168.3.24

Sent EOF message
Server sent command exit status 0
Disconnected: All channels closed



-e "Fehler bei Datei <information2.txt> um Thu Oct 30 10:18:06 2008\n"



Looking up host "192.168.3.24"
Connecting to 192.168.3.24 port 22
Server version: SSH-2.0-OpenSSH_4.2
We claim version: SSH-2.0-PuTTY_Release_0.60
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-rsa 1024 80:c5:8f:44:74:72:1c:8c:7b:b5:72:6f:f7:35:87:b9
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Reading private key file "C:\mykey.ppk"
Using username "rrdexport".
Offered public key
Offer of public key accepted
Authenticating with public key "dsa-key"
Access granted
Opened channel for session
Started a shell/command
information.txt | 32 kB | 32.0 kB/s | ETA: 00:00:07 | 12%
information.txt | 260 kB | 260.1 kB/s | ETA: 00:00:00 | 100%
Using SFTP
Connected to 192.168.3.24

Sent EOF message
Server sent command exit status 0
Disconnected: All channels closed



Gruß
Aendrew
Gast Gast
 2008-10-31 09:52
#115866 #115866
Wegen installieren von Net::SCP (Net::SSH).
Das sind beides einfache Perlmodule. Die kannst du auch einfach irgendwohin kopieren und den Pfad mit "use lib" hinzufügen.
Beispiel:
In /basepath/Net die beiden Dateien SSH.pm und SCP.pm rein kopieren und im Programm "use lib '/basepath';" hinzufügen, dann kannst die Module normal nutzen.
Gast Gast
 2008-10-31 17:12
#115887 #115887
Hi,

jetzt hab ich doch glatt mein Passwort vergessen :(

Naja, vielleicht find ich den Zetteln noch mal *hoff*

@renee: Ich hab jetzt mal versucht das NET::SCP zu installieren, aber unter Windows (das muss ich leider als Server verwenden) funktioniert das leider nicht. (Command scp not found)

Ich hab' es deshalb mit NET::SFTP versucht, aber das geht leider nicht weil mir die oldname.h fehlt.


Kann mir jemand sagen wo ich die oldname.h her bekomme?


Gruß
Aendrew
<< >> 10 Einträge, 1 Seite



View all threads created 2008-10-29 12:04.