diff --git a/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py b/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py index f6f8c3ffd..8c54b9168 100644 --- a/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py +++ b/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py @@ -3,14 +3,11 @@ BASH_STARTUP_FILES = ["~/.bashrc", "~/.profile", "~/.bash_profile"] def get_linux_commands_to_modify_shell_startup_files(): return [ - 'if [ -f {0} ] ;', # does the file exist? - 'then', - 'echo \"# Succesfully modified {0}\" |', - 'tee -a', - '{0}', # add comment to file + 'echo \"# Succesfully modified {0}\"', + '3<{0} 3<&- |', # check for existence of file + 'tee -a', # append to file + '{0}', '&&', - 'sed -i \'$d\' {0} ;', # remove last line of file - 'else', - 'echo \"{0} does not exist\" ; fi' # mention if file does not exist + 'sed -i \'$d\' {0}', # remove last line of file ],\ BASH_STARTUP_FILES