how do I write SSH command output with only values I need -


i creating vps api provided command line. output of command comes several text inside don't need. command.

the variables predefined , work fine.

echo y | /usr/local/bin/clicmd vm create --hostname=$vmname --domain=$srvdomain --cpu 1 --memory 1024 --image $image --datacenter=$dc --billing=hourly -n 100 > /dev/null 1>> /home/logs/createvps.log 

when run it, gives me following output in createvps.log file,

this action incur charges on account. continue? [y/n]: id 11232312
created 2015-06-13t14:43:27-05:00
guid xxxxxx-r345-4323-8e3f-c8c04e18fad7

from above output, need have id (11232312) value stored in mysql table. know how grab value log file , save in mysql.

my question is, how save id in log file instead of other values/strings.

thank in advance.

not sure question, guess should you:

echo y | /usr/local/bin/clicmd vm create --hostname=$vmname \  --domain=$srvdomain --cpu 1 --memory 1024 --image $image \  --datacenter=$dc --billing=hourly -n 100 | \  grep -oe "id [0-9]+$" | grep -eo "[0-9]+" >> /home/logs/createvps.log 

few notes difference in code , mine:

  • you 2 redirection of stdout, 1 /dev/null , 1 log, equivalent of doing 1 redirection (writing in /dev/null practically nop).

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -