I am building a small network of Raspberry Pi's using Raspian with samba file sharing. I want each to be able to read/write small text files to the others, to provide a very simple method of process co-ordination. I am a testing the method with one Pi with a single shared file and can read/write to it from an Ubuntu laptop, using its desktop file manager. I am trying to do the same programmatically:
#include<string>
#include<iostream>
#include<fstream>
using namespace std;
void read_file () {
string line;
ifstream myfile;
myfile.open("\\\\192.168.1.78\\home\\pi\\new2.txt");
if (myfile.is_open()){
cout << "file is open" << endl;
getline(myfile, line);
cout<< line << endl;
} else {
perror("Error");
}
myfile.close();
}
int main(){
read_file();
}
The error message is 'No such file or directory'. I'm guessing this is either a permissions problem I've not seen (the remote file is shared as 777) or the way I'm referencing the server and folder. I've tried numerous combinations to no avail.
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire