0)
Try that in the Interactive Ruby (irb) and you will get the problem.
1)
user_name is your local defined variable, $user_name is another, global
variable name.
$user_name.nil? # returns true
2)
If you want to use your variable in a string you have to use doublequotes "
instead of singlequotes ' and in ruby you can use the following syntax:
"mystring #{var}"
"mystring "+ var
"mystring " << var
one simple solution with proof of shell injection is:
tries = 0
username = ""
while not username.match(/\A[a-zA-Z0-9]+\Z/)
tries = tries.succ
exit! if tries > 3
print "username: "
username = gets.chomp.strip
end
system('adduser -m ' + username)
i am using Ruby for programming in the Linux OS not in Windows, so
plz help me to Run command after Prompting from User... on Linux
operating system, i want to add users to the linux os by using the Ruby
Programming....