ukscotth Posted February 27, 2014 Share Posted February 27, 2014 #!/bin/bash clear echo "Enter username :" read username cd / cd /home/$username/ Hi, I'm new to batch scripting and i'm trying to insert a variable into a command but cant get it working, can someone please tell me how I do the following properly : Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/286583-using-a-variable-in-a-command/ Share on other sites More sharing options...
Zane Posted February 27, 2014 Share Posted February 27, 2014 Do the following? ... what is following what? Quote Link to comment https://forums.phpfreaks.com/topic/286583-using-a-variable-in-a-command/#findComment-1470953 Share on other sites More sharing options...
ukscotth Posted February 27, 2014 Author Share Posted February 27, 2014 Sorry I meant how would I do the code I attached correctly Quote Link to comment https://forums.phpfreaks.com/topic/286583-using-a-variable-in-a-command/#findComment-1470974 Share on other sites More sharing options...
jazzman1 Posted February 28, 2014 Share Posted February 28, 2014 What do you want to achieve? To change the current prompt based on the last directory command when all commands of the script are finished or just to list all sub-directories and files during the process? Quote Link to comment https://forums.phpfreaks.com/topic/286583-using-a-variable-in-a-command/#findComment-1471025 Share on other sites More sharing options...
ukscotth Posted February 28, 2014 Author Share Posted February 28, 2014 The above code was just an example. Im simply trying to learn how to use variables in commands. In php I would use quotes and dots such as echo 'hello'.$world Is there a similar way in batch scripting ? Quote Link to comment https://forums.phpfreaks.com/topic/286583-using-a-variable-in-a-command/#findComment-1471035 Share on other sites More sharing options...
jazzman1 Posted February 28, 2014 Share Posted February 28, 2014 The name of the language is "BASH" no "BATCH". So, learn the basics first before to practise. I'm using this resource. Quote Link to comment https://forums.phpfreaks.com/topic/286583-using-a-variable-in-a-command/#findComment-1471043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.