mkdir -p command for network folder missing something - mkdir

I'm not very good at using the command line or applescript. I found the following but something is missing
It creates the folder on my computer, not the server. Please help me understand what quotes or
lines I have in the wrong place.( sorry I do not know the lingo)
the new folder I want to create is a variable $ID (ex IN19535) it represents a students record
The server is mounted successfully prior to running this shell script through applescript and a calculated field in FMP 11
I want to make the folder $ID in the StudentRecords folder.
do shell script \"mkdir -p \" & quoted form of \"/Volumes/Departments/StudentRecords/" & $ID & "\"
Thank you for your help, I am extremely frustrated.

Related

How to use command prompt to list file names in directory but exclude 1st 3 characters

I'm trying to write some vba code that sends a line of code to the command prompt and executes it. I have that part down, but I need help getting the actual code to work.
I want to list all of the files in a specific folder that are the .doc file extension, but I want to exclude the first three characters of the filename that gets printed to my output text file. (Note: I'm using vba because this is one of several different commands I'd like to get into a single vba macro, and I cannot use batch files b/c they are blocked on my system so I'd like to work directly with the command prompt)
The following code works and gives me the file names without the file extension (ie. ABC201704.doc will return as ABC201704)
*%comspec% /c for %i in (C:\Test\ABC*.doc) do #echo %~ni >> C:\Test\Output.txt*
However, I don't know how to modify this so that it doesn't include the first 3 characters (ie. I'd like it to return 201704 instead of ABC201704).
Any help would be greatly appreciated! I tried using the following link, but I couldn't figure out how to get that to work for my situation.
Not tested:
#echo off
setlocal enableDelayedExpansion
for %%a in ("C:\Test\ABC*.doc") do (
set docname=%%~nxa
echo !docname:~3!
)
In command prompt:
cmd /v:on /c "for %a in ("C:\Test\ABC*.doc") do set docname=%~nxa & echo !docname:~3!"

How to create .dmg of a folder from objective-c or terminal?

Scenario
I need to convert a folder to .dmg using objective-c however, I am not able find any script in obj-c that is why I am looking for a terminal command that can do this.
Research
I am using the given below terminal command in order to convert a folder to .dmg
hdiutil create -format UDZO -srcfolder
"/Users/Paxcel/Desktop/IMG"
"/Users/Paxcel/Desktop/IMG.dmg"
Problem
The above command is not working and giving no result as shown in the screenshot given below:
Please suggest a solution that can help me create a .dmg file of a folder. Many thanks for your attention.
P.S: I have to use either obj-c or terminal because I am creating an utility in cocoa app.
Using " was a mistake. I am from windows world and there (in windows) you always have to put a path into quotes "c://test.txt"
Earlier (Wrong)
hdiutil create -format UDZO -srcfolder
"/Users/Paxcel/Desktop/IMG"
"/Users/Paxcel/Desktop/IMG.dmg"
Correct
hdiutil create -format UDZO -srcfolder
/Users/Paxcel/Desktop/IMG
/Users/Paxcel/Desktop/IMG.dmg
However if you path contains spaces then if you use quotes then it will give an error like given below
Resolution
In order to escape the error you must use '\' before spaces ' ' as given below:
hdiutil create -format UDZO -srcfolder
/Users/Paxcel/Desktop/IMG\ for\ design
/Users/Paxcel/Desktop/IMG\ for\ design.dmg
I have run both commands and the result is shown in the screen shot given below
Quoted path is not working but using '\' in path is working like a charm
You have a stray " in your command line.
The > prompt means more please; the shell wants you to terminate the ".

Launching exe with parameters containing whitespace from vb.net

What I need to do:
I have a path (copied from a working shortcut) to an .exe that I need to launch from my vb.net application. Following Path:
"C:\Program Files (x86)\Citrix\ICA client\pnagent.exe" /CitrixShortcut: (2) /QLaunch "Farm1:ADS # Citrix"
My problem:
I cannot figure out how to do this. My best guess was
Process.Start("cmd", "/k " & path)
But that always ends up with cmd giving back
'C:\Program' is not recognized as an internal or external ...
I know this is due to the path not being properly escaped, but I can't figure out how to do it properly. I know about using Double-Doubblequotes ("") but I couldn't get that work either.
If anyone can point me to a maybe better way to do this than Process.Start() I'd be very happy aswell!
I think the Process.Start() overload you want is
Process.Start(program, args).
... which would give you
Process.Start("C:\Program Files (x86)\Citrix\ICA client\pnagent.exe", "/CitrixShortcut: (2) /QLaunch ""Farm1:ADS # Citrix"" ")
Edit / Clarification:
cmd /k launches the command shell (aka "DOS prompt") but keeps it open after running the specified command (as opposed to cmd /c which executes the command and then closes the shell).
You typically only start cmd if you want to execute a shell built-in like DIR or COPY.
Dim MyProcess as string = "C:\Program Files (x86)\Citrix\ICA client\pnagent.exe"
Dim MyArgs as string = "/CitrixShortcut: (2) /QLaunch ""Farm1:ADS # Citrix"""
Process.Start(MyProcess, MyArgs)

How can I use source script with variables in CygWin?

I'm trying to use external script with variables, but in result I get only "no such file or directory".
1st.ksh
#!bin/ksh
PATHNAME = `dirname $0`
. $PATHNAME/2nd.ksh
Echo $EXTVAR
2nd.ksh
#!bin/ksh
EXTVAR=1
I tried to use "Source" instead of "." (Source $PATHNAME/2nd.ksh) and I get the same result.
To run script I'm using full path to the script - cygdrive/e/Folder/1st.ksh.
2nd.ksh in this path too (cygdrive/e/Folder/).
All rights was granted for both files (chmod u=rwx,g=rwx,o=rwx filename).
If I put files in cygwin home path (/home/username/) I have the same.
Please help to understand what I'm doing wrong.
Thanks in advance!
$() should be used in ksh instead of `` (link)
. should be user instead of source (link)
"=" must not be surrounded with spaces. You should write: PATHNAME=$(dirname $0)
you should be aware of case-sensitiveness: echo, source

Check whether process running linux and start with certain description

I have multiple scripts running. All the scripts have the same name but the commands they execute are doing different things.
I am trying to figure out if a certain instance of the script is running and if so I don't want it to run again. This is difficult because all of the scripts have the same name so it could be a false positive by using pgrep.
My idea was if there is any attribute or description I could attach when it is first run, then I can grep for that unique description and tell which instance is running, is there any way to do this?
Does anyone have any other ideas?
Thanks
You can implement below logic to check weather script is already running or not.
if [ -f Script1.lck ];then
echo "ALREADY INSTANCE RUNNING `date`"
echo "EXITING"
else
echo "NO INSTANCE RUNNING "
touch Script1.lck
#Your Script code here.............
rm -f Script1.lck
fi
*I used concept that every time it runs checks for Script1.lck file if file not exists than it means no instance is running. So it creates file and start executing your code.
Suppose in between you executed the script then it checks for .lck file and and .lck already exists due to previous instance.
*In last i removed the .lck file.
*By using different lck file names for different script you can check which script is running.