Jump to content

Script to get input from user ,check in csv file and read corresponding values and pass that value to cmd


Recommended Posts

Posted

Hi all,

I have a csv file as below, I wand to find srno from csv and send corresponding ip and pass to commend cmd prompt. 

Please guide me to create script .

srno,name,ip,pass

1,name1,ip1,pass1

2,name2,ip2,pass2

 

 

 

 

  • Moderators
Posted

MadhaN,

Before we go any further, please explain why you are storing usernames and passwords in an insecure csv file. And just what are you doing that requires these to be passed to a command prompt?

M23

P.S. And just to be absolutely clear - this is the Mod team determining the legality of the thread, so everyone else please keep out.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

@Melba23

I want to connect to rdp of the remote computer, instead of entering id password every time i want to save .

Since i have to connect 500+ computers i cannot enter every time , I have the script in bat, But i want in  autoit script.

 

Please help me in this.

  • Moderators
Posted

MadhaN,

But you really keep these usernames and passwords in a simple csv file? Does your boss know you do this?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Moderators
Posted

MadhaN,

Sorry for the delay in replying - local internet outage.

I am happy for the thread to remain open - but I hope any responders offer sensible suggestions as to how you might add some level of security to the whole affair because at it stands you are a disaster waiting to happen.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

@MadhaN - Here your title : Script to get input from user ,check in csv file and read corresponding values and pass that value to cmd

 Script to get input from user : use Koda to create a GUI for the user to enter the inputs your require

Check in csv file and read corresponding values : use File.au3 UDF (FileReadtoArray) along with StringSplit to get values

Pass that value to cmd : use run* function to pass values

I would also recommend that you encrypt your csv file with the UDF Encrypt.au3 and decrypt it as needed.

Happy scripting !

Posted (edited)

@MadhaN
In this forum, the motto is "Teach a man to fish" instead of "Give a man a fish", so, since you are asking for an example, and the Help file is full of commented examples, you already have what you need.

EDIT:
Seems that you already have a thread locked by @Jos with the same subject and same questions, always without providing any code.

Edited by FrancescoDiMuro

Click here to see my signature:

  Reveal hidden contents

 

  • Moderators
Posted

MadhaN,

I have now seen that other thread. Either start posting some code that YOU have written to try and do what you want - you have been given some excellent pointers above. It does not matter if it does not work correctly - but YOU need to make some effort or I will lock this thread too.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Hi All,

Created below script to get details and send to CMD but want to search in csv or xls, Please guide me.

 

global $ip
Global $usr
Global $pass

$ip = InputBox("Enter IP" , " Enter IP to take Remote")
$usr = InputBox("Enter usr" , " Enter usr to take Remote")
$pass = InputBox("Enter Pass" , " Enter Pass to take Remote")

Run("C:\WINDOWS\system32\cmd.exe")
$win=WinWaitActive("C:\WINDOWS\system32\cmd.exe")
send('rdp /v:' & $ip &' '&'/u:'&$usr &' ' &'/p:'&$pass & "{ENTER}")

;Sleep(1400)

;send('rdp /v:' & $ip & '/u:'&$usr &'/p:'&$pass & "{ENTER}")

 

Posted (edited)

Congrats @MadhaN.  You are almost there.

Add those 2 UDF at the very beginning of your script, so you have access to the functions you need :

#include <Array.au3>
#include <File.au3>

Now look at _FileReadToArray.  If your csv file is perfectly balanced, you can create a 2D array with this statement only.

Then use _ArraySearch to compare your inputs with the content of the array.

Edited by Nine
Posted

@Nine

Hi , my csv have more thn 1000 rows and 6 columns , please guide me to create 2d array and search .

IF possible provide me simple example script , I checked in help file i cannot understand proper since i have no knowledge in scripting. 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...