Hi All,
I'm pretty new to the forum and also to UNIX. I have a requirement for which I need some help. I have a script (example.script) where I get user inputs using the read command. I would need to pass the read-fetched input to a perl command (explained below) in my script. The part which confuses me is that the input has characters like / and . which has to manipulated. Please help me on the same. Below are the files.
test.file: (Current)
--------
-
-
.LOGON SERVER/userid,password;
-
-
test.file: (Expected)
--------
-
-
.RUN FILE /home/user/my.test.logon;
-
-
example.script:
--------------
echo " Please enter the path to the LOGON file: \c"
read logon
perl -p -i -e "s/^\.LOGON.*$/.RUN FILE $logon;/g" test.file
I execute the example script as:
$ ksh example.script
Please enter the path to the LOGON file: /home/user/my.test.logon
While running the above code, I am getting the below error message:
I hope this is because of using characters / and . in the input string without escape sequences (\). But basically I want input to be entered without escape characters, like in /home/user/my.test.logon, as it will be entered by all users. Is there a way in UNIX where I can have the input entered as-is and still I will be able to format the input before parsing it?
Any help on this is greatly appreciated.
Thanks in Advance. Let me know for any questions.