-1

I need to execute some shell scripts along my project:

restoreBackup(timestamp) {
  return runCommand(`backup_restore.sh ${timestamp}`);
},

The timestamp has to be passed to the script in the form of a unix timestamp. e.g. 1513252423 The Timestamp is set or passed:

restoreBackup(timestamp,callback) {
    backup.restoreBackup(timestamp)
      .then(callback)
      .catch(err => callback(err));
  }

Problem is that my current solution doesn't work, it is kind of derived from the call I use directly on bash. The timestamp is not passed as unix time, but converted to a string, this is the output in the node console:

Running cmd: /home/essentim/manager/scripts/backup_restore.sh Thu Dec 14 2017 11:53:43 GMT+0000 (UTC)
error handler:
"/bin/sh: 1: Syntax error: \"(\" unexpected"

Any Idea how to solve this in this case?

Hias
  • 1
  • 1
  • can you log your timestamp and show? – Sunil Lama Dec 14 '17 at 14:12
  • Not sure I follow, what do you mean by "my current solution doesn't work"? What timestamp are you passing and what timestamp is that command receiving? – Ghabriel Nunes Dec 14 '17 at 14:40
  • the problem is it seems that ${timestamp} does not pass the unix time stamp it kind of makes a string like "14 December 2017 1X:XX:XX" out of it. – Hias Dec 14 '17 at 14:42
  • Show the code where you set the value of timestamp. Then show the value of timestamp you call, what value you get in the function. – Nic3500 Dec 14 '17 at 17:43
  • restoreBackup(timestamp,callback) { backup.restoreBackup(timestamp) .then(callback) .catch(err => callback(err)); } – Hias Dec 15 '17 at 07:21

1 Answers1

0

this is my workaround, which is working for now!

restoreBackup(timestamp) {
    timename = new Date(timestamp).getTime()/1000;
    return runCommand(`backup_restore.sh ${timename}`);
  },

took it from: Convert normal date to unix timestamp

Thx

Hias
  • 1
  • 1