0

I am trying to create a file and write to it using a .sh script but is not working(Nothing is being created, and I don't see any error).

This is how that part of my script looks like:

facesConfigContent="<?xml version='1.0' encoding='UTF-8'?>
<faces-config version=\"2.2\"
              xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\"
              xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
              xsi:schemaLocation=\"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd\">
</faces-config>"
facesConfigFileName="faces-config.xml"
cd ~/Desktop/${artifactId}/src/main/webapp/WEB-INF
echo ${facesConfigContent} > ${facesConfigFileName} 

Do you see something wrong?

3
  • 1
    You are using multiple quotes, so my guess is either with the multiple quotes or 'cd ~/Desktop/${artifactId}/src/main/webapp/WEB-INF" is also ambiguous. You should use the full path in scripts. You should probably use a "here-doc" tldp.org/LDP/abs/html/here-docs.html or read the doc from a file (source it)
    – Panther
    Oct 14, 2013 at 19:04
  • @bodhi.zazen I scaped them correctly. Do you think they are wrong?
    – sfrj
    Oct 14, 2013 at 19:27
  • The quotes are fine. Are you even using bash, because the ~ will not be known in sh. Follow above suggestion to use full path.
    – ubfan1
    Oct 14, 2013 at 19:47

1 Answer 1

1

What exactly is $artifactId ?? If I try to run your code by modifying it like this, it work perfectly fine, so there must be some problem in your cd command

facesConfigContent="<?xml version='1.0' encoding='UTF-8'?>
<faces-config version=\"2.2\"
          xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\"
          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
          xsi:schemaLocation=\"http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd\">
</faces-config>"
facesConfigFileName="faces-config.xml"
cd ~/Desktop/
echo ${facesConfigContent} > ${facesConfigFileName} 
1
  • ${artifactId} is just a variable that came from a read command. Thanks for the answer
    – sfrj
    Oct 16, 2013 at 20:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .