Search Results

Search found 6758 results on 271 pages for 'shell exec'.

Page 66/271 | < Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >

  • Escaping Code for Different Shells

    - by Jon Purdy
    Question: What characters do I need to escape in a user-entered string to securely pass it into shells on Windows and Unix? What shell differences and version differences should be taken into account? Can I use printf "%q" somehow, and is that reliable across shells? Backstory (a.k.a. Shameless Self-Promotion): I made a little DSL, the Vision Web Template Language, which allows the user to create templates for X(HT)ML documents and fragments, then automatically fill them in with content. It's designed to separate template logic from dynamic content generation, in the same way that CSS is used to separate markup from presentation. In order to generate dynamic content, a Vision script must defer to a program written in a language that can handle the generation logic, such as Perl or Python. (Aside: using PHP is also possible, but Vision is intended to solve some of the very problems that PHP perpetuates.) In order to do this, the script makes use of the @system directive, which executes a shell command and expands to its output. (Platform-specific generation can be handled using @unix or @windows, which only expand on the proper platform.) The problem is obvious, I should think: test.htm: <!-- ... --> <form action="login.vis" method="POST"> <input type="text" name="USERNAME"/> <input type="password" name="PASSWORD"/> </form> <!-- ... --> login.vis: #!/usr/bin/vision # Think USERNAME = ";rm -f;" @system './login.pl' { USERNAME; PASSWORD } One way to safeguard against this kind of attack is to set proper permissions on scripts and directories, but Web developers may not always set things up correctly, and the naive developer should get just as much security as the experienced one. The solution, logically, is to include a @quote directive that produces a properly escaped string for the current platform. @system './login.pl' { @quote : USERNAME; @quote : PASSWORD } But what should @quote actually do? It needs to be both cross-platform and secure, and I don't want to create terrible problems with a naive implementation. Any thoughts?

    Read the article

  • Java access Shellfolder

    - by Ripei
    Hello Guys I am trying to access an Shellfolder like: "Shell:::{35786D3C-B075-49b9-88DD-029876E11C01}" via Java on a Windows PC ... but I havn't found a way to do so up to now. Is this generally possible with Java? Recently I uncovered the sun.awt class "ShellFolder"... Does this class provide the abilitiy to access such an folder? thanks for your help Ripei

    Read the article

  • How can I access windows file preview icons from my WPF application

    - by Jobi Joy
    I got a bunch of Pictures and Videos in a directory and needs to be displayed in the WPF application, I am thinking about displaying the Win7 Large Icon itself as the preview image. Because that will save me the work of grabbing an appropriate frame from the video file since Windows is doing that job pretty well already. Any code snippet to access this Shell Icon image data?

    Read the article

  • C#: How to use SHOpenFolderAndSelectItems

    - by Svish
    Could someone give an example on how to use the shell function SHOpenFolderAndSelectItems from C#? I don't quite get how to use these kind of functions and couldn't find it on pinvoke.net... =/ Say I have three files called X:\Pictures\a.jpg X:\Pictures\s.jpg X:\Pictures\d.jpg I then want to open up the X:\Pictures folder with a.jpg, s.jpg and d.jpg selected.

    Read the article

  • How to test crontab entry?

    - by Mark
    I have an entry in my crontab that looks like this: 0 3 * * * pg_dump mydb | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz That script works perfectly when I execute it from the shell, but it doesn't seem to be running every night. I'm assuming there's something wrong with the permissions, maybe crontab is running under a different user or something. How can I debug this? I'm a shared hosting environment (WebFaction).

    Read the article

  • Best way to do text processing in linux/mac ?

    - by euphoria83
    I generally need to do a fair amount of text processing for my research, such as removing the last token from all lines, extracting the first 2 tokens from each line, splitting each line into tokens, etc. What is the best way to perform this ? Should I learn Perl for this? Or should I learn some kind of shell commands? The main concern is speed. If I need to write long code for such stuff, it defeats the purpose.

    Read the article

  • How do I create a custom network connection entry?

    - by David Brown
    I have a Sprint MiFi 3G router that exposes its current signal strength over HTTP. I've developed a very simple tray application that displays this. However, what I would really like to do is create a custom network connection entry so the router's 3G signal strength (along with the current network version) displays when clicking on the network connections tray icon (in Windows 7, at least). Is it possible to do this with a shell extension or something (preferably in C#)? If so, how?

    Read the article

  • Why is the value if this string executing in a bash script?

    - by Ross
    Hello Why is this script executing the string in the if statement: #!/bin/bash FILES="*" STRING='' for f in $FILES do if ["$STRING" = ""] then echo first STRING='hello' else STRING="$STRING hello" fi done echo $STRING when run it with sh script.sh outputs: first lesscd.sh: line 7: [hello: command not found lesscd.sh: line 7: [hello hello: command not found lesscd.sh: line 7: [hello hello hello: command not found lesscd.sh: line 7: [hello hello hello hello: command not found lesscd.sh: line 7: [hello hello hello hello hello: command not found hello hello hello hello hello hello p.s. first attempt at a shell script thanks

    Read the article

  • Inserting text in a file from a variable

    - by user754905
    I have a file that looks something like this: ABC DEF GHI I have a shell variable that looks something like this: var="MRD" What I want to do, is to make my file look like this: ABC MRD DEF GHI I was trying to do this: sed -i -e 's/ABC/&$var/g' text.txt but it only inserts $var instead of the value. I also tried this: sed -i -e 's/ABC/&"$var"/g' text.txt but that didn't work either. Any thoughts? Thanks!

    Read the article

  • COM library for Explorer-like system views

    - by chrisd
    To provide a Windows Explorer-like view of the user's system, we have been using the shell controls from LogicNP (formerly Sky Software), but these have deficiencies, e.g., no support for Win7 libraries. The vendor has not responded to our inquiries about updates, so we're looking to replace the package. Requirements: ActiveX (no managed code or MFC) Tree and list views of the system Per-item checkboxes 32- and 64-bit versions Any recommendations for a replacement product? TIA.

    Read the article

  • Combining echo and cat on Unix

    - by Dan
    Really simple question, how do I combine echo and cat in the shell, I'm trying to write the contents of a file into another file with a prepended string? If /tmp/file looks like this: this is a test I want to run this: echo "PREPENDED STRING" cat /tmp/file | sed 's/test/test2/g' > /tmp/result so that /tmp/result looks like this: PREPENDED STRINGthis is a test2 Thanks.

    Read the article

  • Customized command line parsing in Python

    - by Moshe
    I'm writing a shell for a project of mine, which by design parses commands that looks like this: COMMAND_NAME ARG1="Long Value" ARG2=123 [email protected] My problem is that Python's command line parsing libraries (getopt and optparse) forces me to use '-' or '--' in front of the arguments. This behavior doesn't match my requirements. Any ideas how can this be solved? Any existing library for this?

    Read the article

  • Cut a file based on a text marker

    - by Mustafa
    I have a text file that has the following layout: text text .. CUT HERE text text .. The literal CUT HERE appears only once. What I want to do using shell scripting, is to produce another file containing all the text below CUT HERE, i.e. ignore whatever above CUT HERE. Thanks.

    Read the article

  • How do I run a sudo command in Emacs?

    - by Inaimathi
    I tried using shell-command, but it just does something like this: Sudo password: incorrect, try again. Sudo password: incorrect, try again. Sudo password: incorrect, try again. Failed three attempts. without actually asking for a password. I don't want to have to start up Emacs using sudo emacs, but I guess that's an option if nothing else will work.

    Read the article

  • log4bash: Cannot find a way to add MaxBackupIndex to this logger implementation

    - by Syffys
    I have been trying to modify this log4bash implementation but I cannot manage to make it work. Here's a sample: #!/bin/bash TRUE=1 FALSE=0 ############### Added for testing log4bash_LOG_ENABLED=$TRUE log4bash_rootLogger=$TRACE,f,s log4bash_appender_f=file log4bash_appender_f_dir=$(pwd) log4bash_appender_f_file=test.log log4bash_appender_f_roll_format=%Y%m log4bash_appender_f_roll=$TRUE log4bash_appender_f_maxBackupIndex=10 #################################### log4bash_abs(){ if [ "${1:0:1}" == "." ]; then builtin echo ${rootDir}/${1} else builtin echo ${1} fi } log4bash_check_app_dir(){ if [ "$log4bash_LOG_ENABLED" -eq $TRUE ]; then dir=$(log4bash_abs $1) if [ ! -d ${dir} ]; then #log a seperation line mkdir $dir fi fi } # Delete old log files # $1 Log directory # $2 Log filename # $3 Log filename suffix # $4 Max backup index log4bash_delete_old_files(){ ##### Added for testing builtin echo "Running log4bash_delete_old_files $@" &2 ##### if [ "$log4bash_LOG_ENABLED" -eq $TRUE ] && [ -n "$3" ] && [ "$4" -gt 0 ]; then local directory=$(log4bash_abs $1) local filename=$2 local maxBackupIndex=$4 local suffix=$(echo "${3}" | sed -re 's/[^.]/?/g') local logFileList=$(find "${directory}" -mindepth 1 -maxdepth 1 -name "${filename}${suffix}" -type f | xargs ls -1rt) local fileCnt=$(builtin echo -e "${logFileList}" | wc -l) local fileToDeleteCnt=$(($fileCnt-$maxBackupIndex)) local fileToDelete=($(builtin echo -e "${logFileList}" | head -n "${fileToDeleteCnt}" | sed ':a;N;$!ba;s/\n/ /g')) ##### Added for testing builtin echo "log4bash_delete_old_files About to start deletion ${fileToDelete[@]}" &2 ##### if [ ${fileToDeleteCnt} -gt 0 ]; then for f in "${fileToDelete[@]}"; do #### Added for testing builtin echo "Removing file ${f}" &2 #### builtin eval rm -f ${f} done fi fi } #Appender # $1 Log directory # $2 Log file # $3 Log file roll ? # $4 Appender Name log4bash_filename(){ builtin echo "Running log4bash_filename $@" &2 local format local filename log4bash_check_app_dir "${1}" if [ ${3} -eq 1 ];then local formatProp=${4}_roll_format format=${!formatProp} if [ -z ${format} ]; then format=$log4bash_appender_file_format fi local suffix=.`date "+${format}"` filename=${1}/${2}${suffix} # Old log files deletion local previousFilenameVar=int_${4}_file_previous local maxBackupIndexVar=${4}_maxBackupIndex if [ -n "${!maxBackupIndexVar}" ] && [ "${!previousFilenameVar}" != "${filename}" ]; then builtin eval export $previousFilenameVar=$filename log4bash_delete_old_files "${1}" "${2}" "${suffix}" "${!maxBackupIndexVar}" else builtin echo "log4bash_filename $previousFilenameVar = ${!previousFilenameVar}" fi else filename=${1}/${2} fi builtin echo $filename } ######################## Added for testing filename_caller(){ builtin echo "filename_caller Call $1" output=$(log4bash_abs $(log4bash_filename "${log4bash_appender_f_dir}" "${log4bash_appender_f_file}" "1" "log4bash_appender_f" )) builtin echo ${output} } #### Previous logs generation for i in {1101..1120}; do file="${log4bash_appender_f_file}.2012${i:2:3}" builtin echo "${file} $i" touch -m -t "2012${i}0000" ${log4bash_appender_f_dir}/$file done for i in {1..4}; do filename_caller $i done I expect log4bash_filename function to step into the following if only when the calculated log filename is different from the previous one: if [ -n "${!maxBackupIndexVar}" ] && [ "${!previousFilenameVar}" != "${filename}" ]; then For this scenario to apply, I'd need ${!previousFilenameVar} to be correctly set, but it's not the case, so log4bash_filename steps into this if all the time which is really not necessary... It looks like the issue is due to the following line not working properly: builtin eval export $previousFilenameVar=$filename I have a some theories to explain why: in the original code, functions are declared and exported as readonly which makes them unable to modify global variable. I removed readonly declarations in the above sample, but probleme persists. Function calls are performed in $() which should make them run into seperated shell instances so variable modified are not exported to the main shell But I cannot manage to find a workaround to this issue... Any help is appreciated, thanks in advance!

    Read the article

  • IContextMenu::GetCommandString Not showing help text in Windows Explorer

    - by Grant
    Hi, i am implementing a shell context menu for windows explorer and have successfully created the menu's. What i am having trouble with is the IContextMenu::GetCommandString method that displays the help text in the status bar when you hover over the selected menu item. When i do hover over each item nothing is displayed, but whats weird is that some of the other items that i didnt create, eg - open, or print have had their help text turned into garbage.. Here is a code sample of IContextMenu::QueryContextMenu & IContextMenu::GetCommandString.. int ShellExtLib.IContextMenu.QueryContextMenu(IntPtr hMenu, uint indexMenu, uint idCmdFirst, uint idCmdLast, uint uFlags) { uint idCmd = idCmdFirst; StringBuilder sb = new StringBuilder(1024); try { if ((uFlags & 0xf) == 0 || (uFlags & (uint)ShellExtLib.CMF.CMF_EXPLORE) != 0) { uint selectedFileCount = Helpers.DragQueryFile(m_hDrop, 0xffffffff, null, 0); if (selectedFileCount == 1) { Helpers.DragQueryFile(m_hDrop, 0, sb, sb.Capacity + 1); Documents.Add(sb.ToString()); } else { // MULTIPLE FILES SELECTED. for (uint i = 0; i < selectedFileCount; i++) { Helpers.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1); Documents.Add(sb.ToString()); } } Helpers.InsertMenu(hMenu, indexMenu++, ShellExtLib.UFLAGS.MF_SEPARATOR | ShellExtLib.UFLAGS.MF_BYPOSITION, 0, null); IntPtr hSubMenu = Helpers.CreateMenu(); if (hSubMenu != IntPtr.Zero) { Helpers.InsertMenu(hSubMenu, 0, ShellExtLib.UFLAGS.MF_STRING | ShellExtLib.UFLAGS.MF_BYPOSITION, idCmd++, "Item 1"); Helpers.InsertMenu(hSubMenu, 1, ShellExtLib.UFLAGS.MF_STRING | ShellExtLib.UFLAGS.MF_BYPOSITION, idCmd++, "Item 2"); Helpers.InsertMenu(hSubMenu, 2, ShellExtLib.UFLAGS.MF_SEPARATOR | ShellExtLib.UFLAGS.MF_BYPOSITION, idCmd++, null); Helpers.InsertMenu(hSubMenu, 3, ShellExtLib.UFLAGS.MF_STRING | ShellExtLib.UFLAGS.MF_BYPOSITION, idCmd++, "Item 3"); Helpers.InsertMenu(hSubMenu, 4, ShellExtLib.UFLAGS.MF_SEPARATOR | ShellExtLib.UFLAGS.MF_BYPOSITION, idCmd++, null); Helpers.InsertMenu(hSubMenu, 5, ShellExtLib.UFLAGS.MF_STRING | ShellExtLib.UFLAGS.MF_BYPOSITION, idCmd++, "Item 4"); Helpers.InsertMenu(hSubMenu, 6, ShellExtLib.UFLAGS.MF_STRING | ShellExtLib.UFLAGS.MF_BYPOSITION, idCmd++, "Item 5"); } Helpers.InsertMenu(hMenu, indexMenu++, ShellExtLib.UFLAGS.MF_STRING | ShellExtLib.UFLAGS.MF_BYPOSITION | ShellExtLib.UFLAGS.MF_POPUP, (uint)hSubMenu, "Main Menu"); Helpers.InsertMenu(hMenu, indexMenu++, ShellExtLib.UFLAGS.MF_SEPARATOR | ShellExtLib.UFLAGS.MF_BYPOSITION, 0, null); return (int)(idCmd - idCmdFirst); } } catch { } return 0; } void ShellExtLib.IContextMenu.GetCommandString(int idCmd, uint uFlags, int pwReserved, StringBuilder commandString, int cchMax) { switch (uFlags) { case (uint)ShellExtLib.GCS.VERB: commandString = new StringBuilder("x"); break; case (uint)ShellExtLib.GCS.HELPTEXTA: commandString = new StringBuilder("y"); break; } } Does anyone have any suggestions? I have read a number of articles on how to build shell extensions and have also been reading MSDN as well.. Thanks.

    Read the article

  • How do I mount a remote Linux folder in Windows through SSH?

    - by Jared
    I'm a blind student currently in a system admin/shell programming class. Although ssh works fine for executing commands like ls, pwd, etc editors do not work well with my screen reader and an ssh session. I was wondering if it is possible to mount a Linux folder over ssh so it appears as a windows drive? This way I could edit any files I needed to with accessible software and not have to constantly use SCP to send files back and fourth.

    Read the article

  • Random number from a range in a Bash Script

    - by Jack
    Hi, I need to generate a random port number between 2000-65000 from a shell script. The problem is $RANDOM is only a 16bit number, so im stuck! PORT=$(($RANDOM%63000+2001)) would work nicely if it wasn't for the size limitation. Does anyone have an example of how I can do this, maybe by extracting something from /dev/urandom and getting it within a range? Thanks.

    Read the article

  • exeuting command in background

    - by tazim
    Hi, Trying to execute shell command in background using pythons commands module >>>import commands >>>output = commands.getstatusoutput("find / > tmp.txt &") sh: Syntax error: ";" unexpected Can anyone explain what is wrong with the syntax ? How should it be executed then ? Tazim.

    Read the article

  • Get file name before the extension

    - by ryanprayogo
    I have some files in the same directory (in UNIX filesystem) that looks like: a.txt.name b.xml.name c.properties.name a.txt.name2 b.xml.name2 c.properties.name2 How do I get the string before the name or name2 part using some shell command? ie. the a.txt, b.xml, c.properties part?

    Read the article

< Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >