Run scripts from a different file (2024)

Register Log In
ForumsActive ThreadsSearchWho's OnlineHelp

Print Thread

Run scripts from a different file (1)

Run scripts from a different file

#23958209/11/12 07:47 AM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (2)OP

Pikka bird

OPRun scripts from a different file (3)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

What sample of code would I use to run set commands in a different file, even though I have a 'master' file with the main commands in it.


Run scripts from a different file (4)

Re: Run scripts from a different file

Judgebot#23958409/11/12 11:15 AM

Joined: Oct 2004

Posts: 8,330

Riamus2Run scripts from a different file (6)

Hoopy frood

Run scripts from a different file (7)

Riamus2

Hoopy frood

Joined: Oct 2004

Posts: 8,330

Just $read the file. Without the n parameter in $read, it will evaluate anything that is read. Be very careful doing that if anyone has access to write something to the file besides you. Doing that sort of thing can be a significant security risk.


Invision Support
#Invision on irc.irchighway.net

Run scripts from a different file (9)

Re: Run scripts from a different file

Riamus2#23958509/11/12 03:06 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (10)OP

Pikka bird

OPRun scripts from a different file (11)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

So what would the code be like?

$read C:\file.text ?


Run scripts from a different file (12)

Re: Run scripts from a different file

Judgebot#23959009/11/12 06:07 PM

Joined: Oct 2004

Posts: 8,330

Riamus2Run scripts from a different file (14)

Hoopy frood

Run scripts from a different file (15)

Riamus2

Hoopy frood

Joined: Oct 2004

Posts: 8,330

For syntax and examples: /help $read

Again, be aware that running commands this way leaves you open to security risks if you aren't careful. Never run a command from a file that people can write to.

Edit: I thought $read() was a little less secure. After I had a chance to test, simply using $read isn't quite enough, but here's one option:

Code:

alias command { noop $read(commands.txt,w,$1*)}

commands.txt file:

Quote:

echo_hello | echo -a hello
echo_bye | echo -a bye

Use:
/command echo_hello
/command echo_bye

You can set the text file up with a command name to use followed by a pipe character and then followed by the command. The just specify the command name when using the command as shown and it will run the command in the text file that matches the command name you used.

You would of course have to adjust this to fit your needs. It's just a basic example.


Last edited by Riamus2; 09/11/12 06:22 PM.

Invision Support
#Invision on irc.irchighway.net

Run scripts from a different file (17)

Re: Run scripts from a different file

Riamus2#23959309/11/12 06:59 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (18)OP

Pikka bird

OPRun scripts from a different file (19)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

OK I will test this now.


Run scripts from a different file (20)

Re: Run scripts from a different file

Judgebot#23960209/11/12 09:04 PM

Joined: Nov 2006

Posts: 1,559

H

HorstlRun scripts from a different file (21)

Hoopy frood

Run scripts from a different file (22)

Horstl

Hoopy frood

H

Joined: Nov 2006

Posts: 1,559

Or use the /play command and the -c switch. With /play, you don't need that external alias and the other switches allow you to set further parameters, if required.


Run scripts from a different file (23)

Re: Run scripts from a different file

Horstl#23960510/11/12 12:29 AM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (24)OP

Pikka bird

OPRun scripts from a different file (25)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

Originally Posted By: Horstl

Or use the /play command and the -c switch. With /play, you don't need that external alias and the other switches allow you to set further parameters, if required.

Do you have an example/snippet of code that i could look at?


Run scripts from a different file (26)

Re: Run scripts from a different file

Judgebot#23961110/11/12 11:42 AM

Joined: Nov 2006

Posts: 1,559

H

HorstlRun scripts from a different file (27)

Hoopy frood

Run scripts from a different file (28)

Horstl

Hoopy frood

H

Joined: Nov 2006

Posts: 1,559

Create for instance a file "example.txt" and add a set of commands to it:

Code:

window -a "status window" | echo -st starting exampleecho -s ...minimizing and restoring mIRC...showmirc -nshowmirc -recho -st done!

Now within mIRC, if you use the following command:

Code:

/.play -spc "example.txt" 500

mIRC will execute all commands in that file.

Of course you can put the play command inside a custom alias like:

Code:

alias example { .play -spc "example.txt" 500 }

The -c switch tells mIRC to treat all the line in the file as commmands.
The -p switch tells mIRC to give priority to this play request (just in case there are other playbacks running at the moment).
Note that /play requires some target window, therefore I put the -s switch (in mIRC, there will always be a status window).
"500" specifies the per-line playback delay in milliseconds, i.e. the time offset between the different command lines of your file. Note that as the first line in example.txt has two commands on it, there will be no delay in-between the two. You can put "0" for delay to have mIRC execute all the commands without any line delay.

The play command syntax is documented in detail at "playing files" in your mIRC helpfile. For example, you could use an ini-file and have mIRC play a given topic (as the command register, with one or more command line associated to it).


Run scripts from a different file (29)

Re: Run scripts from a different file

Horstl#23961210/11/12 12:33 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (30)OP

Pikka bird

OPRun scripts from a different file (31)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

Originally Posted By: Horstl

Create for instance a file "example.txt" and add a set of commands to it:

Code:

window -a "status window" | echo -st starting exampleecho -s ...minimizing and restoring mIRC...showmirc -nshowmirc -recho -st done!

Now within mIRC, if you use the following command:

Code:

/.play -spc "example.txt" 500

mIRC will execute all commands in that file.

Of course you can put the play command inside a custom alias like:

Code:

alias example { .play -spc "example.txt" 500 }

The -c switch tells mIRC to treat all the line in the file as commmands.
The -p switch tells mIRC to give priority to this play request (just in case there are other playbacks running at the moment).
Note that /play requires some target window, therefore I put the -s switch (in mIRC, there will always be a status window).
"500" specifies the per-line playback delay in milliseconds, i.e. the time offset between the different command lines of your file. Note that as the first line in example.txt has two commands on it, there will be no delay in-between the two. You can put "0" for delay to have mIRC execute all the commands without any line delay.

The play command syntax is documented in detail at "playing files" in your mIRC helpfile. For example, you could use an ini-file and have mIRC play a given topic (as the command register, with one or more command line associated to it).

So there has to be a separate text file for every external command? you can't compile them into one external file?


Run scripts from a different file (32)

Re: Run scripts from a different file

Judgebot#23963912/11/12 04:13 AM

Joined: Nov 2006

Posts: 1,559

H

HorstlRun scripts from a different file (33)

Hoopy frood

Run scripts from a different file (34)

Horstl

Hoopy frood

H

Joined: Nov 2006

Posts: 1,559

Not if you use the .ini file structure. You could place every command (or set of commands) under a distinct [topic] header of a single .ini file.
What goal are you trying to attain by out-sourcing your commands, if I may ask?


Run scripts from a different file (35)

Re: Run scripts from a different file

Horstl#23964712/11/12 03:59 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (36)OP

Pikka bird

OPRun scripts from a different file (37)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

Originally Posted By: Horstl

Not if you use the .ini file structure. You could place every command (or set of commands) under a distinct [topic] header of a single .ini file.
What goal are you trying to attain by out-sourcing your commands, if I may ask?

Say i give someone access to a file called "user1.txt(/.ini)" then they have access to add command to that file.

But then i'd want the main file "remote.ini" to use the commands in that file for said channel.

Then it would go on to add more external files such as user2,3,4,5,6...

The main file structure would then be something like

Code:

on *:text:*:#: { if ( $chan == #user1 ) { $read(user1.txt) }}on *:text:*:#: { if ( $chan == #user2 ) { $read(user2.txt) }}

and so on, permissions and commands would be pulled from the different files.

I'd like the commands in each external file to look like:

Code:

on *:text:*!commandexample*:#: { msg $chan command example}

this is a command example which it would look like in each file. So standard command format.


Last edited by Judgebot; 12/11/12 04:02 PM.

Run scripts from a different file (38)

Re: Run scripts from a different file

Judgebot#23965412/11/12 11:24 PM

Joined: Oct 2004

Posts: 8,330

Riamus2Run scripts from a different file (40)

Hoopy frood

Run scripts from a different file (41)

Riamus2

Hoopy frood

Joined: Oct 2004

Posts: 8,330

You wouldn't be able to use event syntax like that. At least, not without considerable work, or unless you want to load the file and use it that way as just another script file.

As far as what you are attempting, you should absolutely never do this. Consider what happens if someone decides it would be "fun" to put in a command to delete things from your computer or grab your password file from your browser or other history and cookie information from you browser and download it? It would be VERY easy for someone to do basically anything they wanted to your computer. And with that kind of control, they could make it so you don't even notice... write the command to do what they want, then change it back to something innocuous until they are ready to do something bad again.

Never, never, never let someone create their own command on your computer and execute it. This is a really dangerous idea for a script. Unless you and only you have access to write commands, or you can absolutely trust those who have access (I wouldn't trust anyone besides very close family and perhaps very close real life friends). It would never be a good idea to give that kind of control to anyone you meet online no matter how good you think you know them.


Invision Support
#Invision on irc.irchighway.net

Run scripts from a different file (43)

Re: Run scripts from a different file

Riamus2#23967413/11/12 12:49 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (44)OP

Pikka bird

OPRun scripts from a different file (45)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

Originally Posted By: Riamus2

You wouldn't be able to use event syntax like that. At least, not without considerable work, or unless you want to load the file and use it that way as just another script file.

As far as what you are attempting, you should absolutely never do this. Consider what happens if someone decides it would be "fun" to put in a command to delete things from your computer or grab your password file from your browser or other history and cookie information from you browser and download it? It would be VERY easy for someone to do basically anything they wanted to your computer. And with that kind of control, they could make it so you don't even notice... write the command to do what they want, then change it back to something innocuous until they are ready to do something bad again.

Never, never, never let someone create their own command on your computer and execute it. This is a really dangerous idea for a script. Unless you and only you have access to write commands, or you can absolutely trust those who have access (I wouldn't trust anyone besides very close family and perhaps very close real life friends). It would never be a good idea to give that kind of control to anyone you meet online no matter how good you think you know them.

Ok, so is there a script snippet that does:

Code:

!addcommand isop !command command example

Code:

!addcommand public !command command example

!addcommand = the script
isop/public = the permissions
!command = the command you want adding (trigger)
command example = the text of the command (reply)

isop:

Code:

if ( $nick isop $chan )

public:

Code:

on *:text:*!command*:#:{ msg $chan command example }

Run scripts from a different file (46)

Re: Run scripts from a different file

Judgebot#23968313/11/12 11:05 PM

Joined: Sep 2005

Posts: 2,881

H

hixxyRun scripts from a different file (47)

Hoopy frood

Run scripts from a different file (48)

hixxy

Hoopy frood

H

Joined: Sep 2005

Posts: 2,881

Do you just want the script to be able to send messages or does it have to be able to execute other commands?

If the former, there's a much easier (and better) way of achieving what you want.


Run scripts from a different file (49)

Re: Run scripts from a different file

hixxy#23969314/11/12 03:48 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (50)OP

Pikka bird

OPRun scripts from a different file (51)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

Originally Posted By: hixxy

Do you just want the script to be able to send messages or does it have to be able to execute other commands?

If the former, there's a much easier (and better) way of achieving what you want.

I'd like a way of someone else adding commands to the bot, without them touching/giving me the command script to be added.

So any way of doing that (pretty much) I would be great full


Run scripts from a different file (52)

Re: Run scripts from a different file

Judgebot#23969414/11/12 06:07 PM

Joined: Feb 2003

Posts: 3,432

S

spartaRun scripts from a different file (53)

Hoopy frood

Run scripts from a different file (54)

sparta

Hoopy frood

S

Joined: Feb 2003

Posts: 3,432

You can yes, but it's a bad bad idea, i could format your whole computer (or worse) if you give that type of access so it's not a good idea.


Last edited by sparta; 14/11/12 06:08 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Run scripts from a different file (55)

Re: Run scripts from a different file

sparta#23969814/11/12 11:57 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (56)OP

Pikka bird

OPRun scripts from a different file (57)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

Originally Posted By: sparta

You can yes, but it's a bad bad idea, i could format your whole computer (or worse) if you give that type of access so it's not a good idea.

I'd still like to see this script/code please.

the bot is running on a server and all of the programs are backup-ed away from the computer


Run scripts from a different file (58)

Re: Run scripts from a different file

Judgebot#23970715/11/12 11:19 AM

Joined: Oct 2004

Posts: 8,330

Riamus2Run scripts from a different file (60)

Hoopy frood

Run scripts from a different file (61)

Riamus2

Hoopy frood

Joined: Oct 2004

Posts: 8,330

You know that the things people can do aren't limited to just that computer, right? If you're on a home network, they can gain access to other computers on the network. They can also easily get you banned from the IRC network and can send out viruses to people from your computer. They can also very easily set your computer up (outside of mIRC) to do things it shouldn't, such as passing on viruses or doing DDOS attacks on places. You are attempting to make it possible for someone to do anything they want from your computer as if they were sitting at the computer itself. This goes beyond whether you have a backup on that computer. It is just a really bad idea.


Invision Support
#Invision on irc.irchighway.net

Run scripts from a different file (63)

Re: Run scripts from a different file

Riamus2#23970815/11/12 08:25 PM

Joined: Nov 2012

Posts: 18

J

JudgebotRun scripts from a different file (64)OP

Pikka bird

OPRun scripts from a different file (65)

Judgebot

Pikka bird

J

Joined: Nov 2012

Posts: 18

Originally Posted By: Riamus2

You know that the things people can do aren't limited to just that computer, right? If you're on a home network, they can gain access to other computers on the network. They can also easily get you banned from the IRC network and can send out viruses to people from your computer. They can also very easily set your computer up (outside of mIRC) to do things it shouldn't, such as passing on viruses or doing DDOS attacks on places. You are attempting to make it possible for someone to do anything they want from your computer as if they were sitting at the computer itself. This goes beyond whether you have a backup on that computer. It is just a really bad idea.

The bot is used on TwitchTv, and I have spoken and know the twitch admins and they know me and the people who the bot will first be used for.



Link Copied to Clipboard

Forum Rules ·Mark All ReadContact Us·Help·mIRC Homepage

Run scripts from a different file (2024)

FAQs

How to execute a script from another directory? ›

When we need to invoke commands in a subshell, we put them in parentheses. Thus, we can see the init.sh script is called inside a subshell after changing the directory. This way, it runs separately without affecting the current shell. With that, we ensure the init directory exists before executing the script.

How do I run a script from a file? ›

Steps to write and execute a script
  1. Open the terminal. Go to the directory where you want to create your script.
  2. Create a file with . sh extension.
  3. Write the script in the file using an editor.
  4. Make the script executable with command chmod +x <fileName>.
  5. Run the script using ./<fileName>.

How do you run a script from another script in Python? ›

In Python, we can run one file from another using the import statement for integrating functions or modules, exec() function for dynamic code execution, subprocess module for running a script as a separate process, or os. system() function for executing a command to run another Python file within the same process.

How to run shell script with full path? ›

You run any program by specifying its name as the first token on a shell commandline. Its absolute name is the full filespec, including all directory names relative to the root directory ( ' / ', not ' /root ' ). As an example, an executable file in your home directory: /home/yourID/theExecutable.

How do I run a program from another directory in command prompt? ›

Type cd [filepath] in the command with your program's file path. Replace [filepath] with the actual path to folder that contains the EXE program you want to run. For example, if you're trying to run Mozilla Firefox, your command here may look like cd C:\Program Files\Mozilla Firefox .

How do I run a script from another user? ›

There are several ways to run a script or command as another user in Linux, such as using the "su" command, the "sudo" command, or the "runuser" command. Each command has its own syntax and options, and it's important to use them with caution and only when necessary.

How to run Python script in another folder? ›

To make Python scripts runnable from any location under Windows:
  1. Create directory to put all your python scripts in. ...
  2. Copy all your python scripts into this directory.
  3. Add the path to this directory in Windows "PATH" system variable: ...
  4. Run or restart "Anaconda Prompt"
  5. Type "your_script_name.py"

How to call a program from another program in Python? ›

run() or subprocess. Popen() with proper arguments to execute commands safely. It is helpful to capture and return the exit code or any other output from the executed Python file if required.

How do I run two Python scripts together? ›

Ensure you have all three Python scripts ( script1.py , script2.py , and run_scripts.py ) in the same directory. Then, execute run_scripts.py . It will run script1.py and script2.py concurrently using multithreading.

How to run shell script without terminal? ›

To run scripts as ordinary programs, we use the indirect method.
  1. 3.1. Direct Call From the Shell. The simplest method to run the script is to call it directly with the required shell. ...
  2. 3.2. Indirect Call From the Shell. More often, however, we start the script as follows from the directory where it's present: $./runme.
Mar 18, 2024

How to set Python path in shell script? ›

Setting PYTHONPATH more permanently
  1. Open Terminal.app ;
  2. Open the file ~/.bash_profile in your text editor – e.g. atom ~/.bash_profile ;
  3. Add the following line to the end: export PYTHONPATH="/Users/my_user/code"
  4. Save the file.
  5. Close Terminal.app ;
  6. Start Terminal.app again, to read in the new settings, and type this:

How to execute a Python script in a different directory? ›

To make Python scripts runnable from any location under Windows:
  1. Create directory to put all your python scripts in. ...
  2. Copy all your python scripts into this directory.
  3. Add the path to this directory in Windows "PATH" system variable: ...
  4. Run or restart "Anaconda Prompt"
  5. Type "your_script_name.py"

How do I run a script remotely? ›

To run a script on one or many remote computers, use the FilePath parameter of the Invoke-Command cmdlet. The script must be on or accessible to your local computer. The results are returned to your local computer.

How to execute a Bash script from any location? ›

In order to run a Bash script from anywhere on your system, you need to add your script to your PATH environment variable. Now that the path to the script is added to PATH, you can call it from where you want on your system. $ script This is the output from script!

How do I run a NPM script from a different directory? ›

To run an npm script from another directory, use --prefix :
  1. npm --prefix <path> run <command>
  2. yarn --cwd <path> <command>
  3. { "scripts": { "command": "echo hello world" } }
  4. npm --prefix ./path/ run command yarn --cwd ./path/ command.
Oct 23, 2020

References

Top Articles
Latest Posts
Article information

Author: Jeremiah Abshire

Last Updated:

Views: 5885

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Jeremiah Abshire

Birthday: 1993-09-14

Address: Apt. 425 92748 Jannie Centers, Port Nikitaville, VT 82110

Phone: +8096210939894

Job: Lead Healthcare Manager

Hobby: Watching movies, Watching movies, Knapping, LARPing, Coffee roasting, Lacemaking, Gaming

Introduction: My name is Jeremiah Abshire, I am a outstanding, kind, clever, hilarious, curious, hilarious, outstanding person who loves writing and wants to share my knowledge and understanding with you.