i want the variable msg to be added to the path like /home/user/map/'msg'. msg is a string type.Anybody knows how? thanks.
socket.on("savemap", function(msg) {
console.log(msg);
var cmd ='rosrun map_server map_saver -f /home/user/map/';
exec(cmd, function(error, stdout, stderr) {
});
});
Simply concatenate using +
.
var cmd = 'rosrun map_server map_saver -f /home/user/map/' + msg;
Or if you are on ES6 or higher, using string templates :
var cmd = `rosrun map_server map_saver -f /home/user/map/${msg}`;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.