Jump to content

mantas

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by mantas

  1. wow that was fast.. only had to add "" on $f variable because there are spaceses in file name. but anyway THANK YOU!!!
  2. Hello, I recently started learning bash and had an idea how to make my life easier with one script, but now I am just pulling my hair with frustration because I can't think of any idea how to exactly do it, so maybe you guys can help me out with this. So what I want to do is that I have one directory with like ~600 .pfd files in it and I want to split(or move) all these files to different directories. I will just write and example which will allow you to understand what i want to do. Lets say all my files are stored in: /home/user/Desktop/list and i have another dir on desktop (lets say it's /home/user/Desktop/Result ) which contains folders like: Item001, Item002, Item003 etc... All i want to is to take first .pdf from (/home/user/Desktop/list) and move it to folder (/home/user/Desktop/Result/Item001) and the take second .pdf and move it to (/home/user/Desktop/Result/Item002) and so on. #!/bin/bash cd /home/user/Desktop/list i=0 while read line do array[ $i ]="$line" (( i++ )) done < <(ls -R) echo ${array[1]} mv "${array[1]}" /home/user/Desktop/Result/Item001 I managed to make a little script which is almost doing what i need, but i do not know how to make this line ( mv "${array[1]}" /home/user/Desktop/Result/Item001) to add like +1.... I know that this probably very noobish-like way of doing it but as i said i just started learning bash and i am not very much experienced in programing at all. Hope someone can enlighten me on this thing. Thanks in advance.
  3. That works like a charm!! thank you
  4. I assume that yes. Lets say that user enter 10 days 0 hours 0 minutes. And i want to use that time in my php script as seconds. so 10 days = 864000 seconds. I would really appreciate you help.
  5. Hello, so basically i am not very experienced in PHP and this script is becoming the biggest challenge for me, probably because I lack of knowledge in PHP, so I am asking for some help and explanations. Explanation of what I am doing: I am trying to create a php script which gonna have a html form to create WIFI user on cisco WLC. I know that WLC it self got this kind of thing, but the reason I want to do it is that I dont want to allow any staff members to connect to WLC even knowing that they are going to have limited rights and so on. So I came-up with this idea that I am going to make this PHP script and HTML form which uses SNMP to create wifi user accounts, that's how I am planning to bypass using WLC interface. So the first thing which drives me nuts is that I need to convert entered time from HTML form to seconds, this form has days, hours, minutes. See attachment. Basically I want to "echo" entered time period in seconds at the bottom of php script but I dont know how. I know that this code is messy and ugly, but the idea itself covers that Code looks like that: Lifetime: days hours mins overall code looks like that(it is still missing PHP_SNMP functions): </pre><form method="POST" action="index.php"> bgColor="#ffffcc" align=center> Host: wlc-1 wlc-2 Username: Password: Lifetime: days hours mins Vlan: ISM Studies < This part of PHP script converts (username, password) input for HTML table to ascii decimal numbers that's because SNMP requires that. $user = $_POST['user']; $pass = $_POST['password']; $host = $_POST['host']; $arr = array($user); $arr2 = array($pass); foreach($arr as $value) { $index = 0; while($index < strlen($value)) { $ascii .= '.' . ord($value[$index]); $dot_separated = implode(".", $value)." "; $index++; } echo $ascii." "; } foreach($arr2 as $value) { $index = 0; while($index < strlen($value)) { $ascii2 .= '.' . ord($value[$index]); $dot_separated = implode(".", $value)." "; $index++; } echo $ascii2." "; } echo $host." "; ?>
×
×
  • Create New...