To output text, use echo
rather than cat
(which outputs data from files or streams).
Aside from that, you will also have to escape the double-quotes inside your text if you want them to appear in the result.
echo -e "Name of your app?\n"
read appname
echo "{apps:[{name:\"${appname}\",script:\"./cms/bin/www\",watch:false}]}" > process.json
If you need to process more than just a simple line, I second @chepner's suggestion to use a JSON tool such as jq
.
Your -bash: process.json: Permission denied
comes from the fact you cannot write to the process.json
file. If the file does not exist, check that your user has write permissions on the directory. If it exists, check that your user has write permissions on the file.
sudo echo
andsudo read
on the first two lines look completely pointless to me – Kutenaisudo vim process.json
it works... – Discrepantvim
opens the file; with> process.json
, the shell opens the file beforesudo
actually runs. – Uncovenanted