Üzgün Kurt
Hectopat
- Katılım
- 17 Şubat 2021
- Mesajlar
- 134
Daha fazla
- Cinsiyet
- Erkek
var JSFtp = require("jsftp");
var ftp = new JSFtp({
host: "ftp.example.com",
user: "username",
pass: "password"
});
ftp.put("evet", "/remote/path/test.txt", function(hadError) {
if (!hadError) {
console.log("TXT dosyası değiştirildi.");
}
});
using System;
using System.IO;
using System.Net;
public static void ChangeFileContent()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftp.example.com/remote/path/test.txt");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("username", "password");
using (Stream fileStream = File.OpenRead(@"C:\local\path\evet.txt"))
using (Stream ftpStream = request.GetRequestStream())
{
fileStream.CopyTo(ftpStream);
}
Console.WriteLine("TXT dosyası değiştirildi.");
}
var JSFtp = require("jsftp");
var ftp = new JSFtp({
host: "ftp.example.com",
user: "username",
pass: "password"
});
ftp.get("/remote/path/test.txt", function(err, socket) {
if (err) {
console.error(err);
}
else {
var chunks = [];
socket.on("data", function(d) {
chunks.push(d);
});
socket.on("close", function(hadErr) {
if (hadErr) {
console.error("Dosya indirilirken hata oluştu.");
}
else {
var fileContent = Buffer.concat(chunks).toString();
if (fileContent.trim() === "evet") {
console.log("TXT dosyası 'evet' olarak ayarlanmış.");
}
else {
console.log("TXT dosyası 'hayır' olarak ayarlanmış.");
}
}
});
socket.resume();
}
});
using System;
using System.IO;
using System.Net;
public static void CheckFileContent()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftp.example.com/remote/path/test.txt");
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential("username", "password");
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
string fileContent = reader.ReadToEnd();
if (fileContent.Trim() == "evet")
{
Console.WriteLine("TXT dosyası 'evet' olarak ayarlanmış.");
}
else
{
Console.WriteLine("TXT dosyası 'hayır' olarak ayarlanmış.");
}
}
}
var JSFtp = require("jsftp");
var ftp = new JSFtp({
host: "ftp.example.com",
user: "username",
pass: "password"
});
var filePath = "/remote/path/test.txt";
var evet = "evet";
var hayir = "hayir";
var zamanlayici = null;
function degistir(yeniIcerik) {
ftp.put(new Buffer(yeniIcerik), filePath, function(err) {
if (err) {
console.error(err);
}
else {
console.log("TXT dosyasının içeriği değiştirildi: " + yeniIcerik);
}
});
}
function kontrolEt() {
ftp.get(filePath, function(err, socket) {
if (err) {
console.error(err);
}
else {
var chunks = [];
socket.on("data", function(d) {
chunks.push(d);
});
socket.on("close", function(hadErr) {
if (hadErr) {
console.error("Dosya indirilirken hata oluştu.");
}
else {
var fileContent = Buffer.concat(chunks).toString();
if (fileContent.trim() === evet) {
degistir(hayir);
}
else {
degistir(evet);
}
}
});
socket.resume();
}
});
}
zamanlayici = setInterval(kontrolEt, 30000); // 30 saniyede bir kontrol et
var evet = "evet";
var hayir = "hayir";
var zamanlayici = null;
function degistir(yeniIcerik) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "degistir.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("yeniIcerik=" + yeniIcerik);
}
function kontrolEt() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
if (xhr.status == 200) {
var fileContent = xhr.responseText;
if (fileContent.trim() === evet) {
// "evet" ise "hayir" yap
degistir(hayir);
alert("TXT dosyasının içeriği 'evet' olarak değiştirildi!");
} else {
// "hayir" ise "evet" yap
degistir(evet);
alert("TXT dosyasının içeriği 'hayir' olarak değiştirildi!");
}
} else {
console.error(xhr.statusText);
}
}
};
xhr.open("GET", "oku.php", true);
xhr.send();
}
zamanlayici = setInterval(kontrolEt, 30000); // 30 saniyede bir kontrol et